Apify Unofficial SDK avatar
Apify Unofficial SDK
Under maintenance
Try for free

No credit card required

View all Actors
This Actor is under maintenance.

This Actor may be unreliable while under maintenance. Would you like to try a similar Actor instead?

See alternative Actors
Apify Unofficial SDK

Apify Unofficial SDK

jupri/apify-unofficial-sdk
Try for free

No credit card required

Apify Unofficial SDK in Other Languanges

Apify Ruby SDK Unofficial

dont be sad readme is here

About Ruby (programming language)

Ruby is an interpreted, high-level, general-purpose programming language which supports multiple programming paradigms. It was designed with an emphasis on programming productivity and simplicity. In Ruby, everything is an object, including primitive data types. It was developed in the mid-1990s by Yukihiro "Matz" Matsumoto in Japan.

About This Actor

Apify Ruby SDK Unofficial Unstable Unsupported Under Maintenance. Inspired by Apify Python SDK

Disclaimer : This library is community library and not supported by Apify

Included :

  • Apify SDK (unofficial)
  • Apify Client (unofficial)

Source Code :

Github

Important Notes (for Ruby beginner like me) :

  • On ruby all evaluated to true except for: false and nil.
  • Function will return value from last expression.

Developer Notes

  • Some method is conflicting with Ruby internal method such as: .initialize, .exit, .fail, etc. Renamed to: .initialize_, .exit_, .fail_ etc.

Installation

git clone https://github.com/JupriGH/apify-ruby-sdk.git
1# import inside script
2require_relative './apify-ruby-sdk/lib/apify_sdk'

Enable Logging

1logger = Apify::Log
2
3# level: INFO | WARN | ERROR | FATAL | UNKNOWN
4logger.level = Logger::DEBUG 
5
6# Formatter
7logger.formatter = Apify::ActorLogFormatter.new

Basic Usage

1# SYNC Mode
2# won't be able to receive platform events (aborting, migration, etc.)
3# for testing on local development (eg: IRB)
4Apify::Actor.main(<callable>)
5
6# ASYNC Mode
7# use on apify platform to receive platform events
8Async do
9	Apify::Actor.main(<callable>)
10end

Example #1

1Apify::Actor.main( lambda { |actor|
2	input = actor.get_input
3	0 # optional exit code
4})

or

1actor = Apify::Actor
2actor.main( lambda {
3	input = actor.get_input
4	0 # optional exit code
5})

Example #2

1def main(actor)
2	input = actor.get_input
3end
4
5Apify::Actor.main( method(:main) )

Using "with" emulator

Use with function to emulate Python context manager

1# SYNC Mode
2with Apify::Actor do |actor|
3	input = actor.get_input
4end
5
6# ASYNC Mode
7Async do
8	with Apify::Actor do |actor|
9		input = actor.get_input
10	end
11end

do ... end can be replaced with { ... }

1Async {
2	with Apify::Actor { |actor|
3		input = actor.get_input
4	}
5}
Developer
Maintained by Community
Actor metrics
  • 3 monthly users
  • 100.0% runs succeeded
  • 0.0 days response time
  • Created in Oct 2023
  • Modified 5 months ago