Class: Mikyung
- Inherits:
-
Object
- Object
- Mikyung
- Defined in:
- lib/mikyung.rb
Overview
iterates following a series of steps provided a goal and a starting uri.
Mikyung.new(objective).run(uri)
Instance Attribute Summary collapse
-
#goal ⇒ Object
readonly
Returns the value of attribute goal.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Mikyung
constructor
initializes with a goal in mind.
-
#run(*args) ⇒ Object
keeps changing from a steady state to another until its goal has been achieved.
Constructor Details
#initialize(*args) ⇒ Mikyung
initializes with a goal in mind
49 50 51 52 |
# File 'lib/mikyung.rb', line 49 def initialize(*args) @goal = args[0] @start = args[1] if args.size==2 end |
Instance Attribute Details
#goal ⇒ Object (readonly)
Returns the value of attribute goal.
46 47 48 |
# File 'lib/mikyung.rb', line 46 def goal @goal end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
46 47 48 |
# File 'lib/mikyung.rb', line 46 def start @start end |
Instance Method Details
#run(*args) ⇒ Object
keeps changing from a steady state to another until its goal has been achieved
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/mikyung.rb', line 55 def run(*args) @start = current = @start || Restfulie.at(args[0]).get Restfulie::Common::Logger.logger.debug current.response.body while(!@goal.completed?(current)) step = @goal.next_step(current) raise "No step was found for #{current} with links #{current.links}" unless step Restfulie::Common::Logger.logger.debug "Mikyung > next step will be #{step}" step = step.new if step.kind_of? Class current = try_to_execute(step, current, 3) end end |