Class: Jsapi::Meta::Callable::SymbolSequenceEvaluator

Inherits:
Object
  • Object
show all
Defined in:
lib/jsapi/meta/callable/symbol_sequence_evaluator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*symbols) ⇒ SymbolSequenceEvaluator

Returns a new instance of SymbolSequenceEvaluator.



9
10
11
12
# File 'lib/jsapi/meta/callable/symbol_sequence_evaluator.rb', line 9

def initialize(*symbols)
  @symbols = symbols
  @callables = symbols.map { |symbol| SymbolEvaluator.new(symbol) }
end

Instance Attribute Details

#symbolsObject (readonly)

Returns the value of attribute symbols.



7
8
9
# File 'lib/jsapi/meta/callable/symbol_sequence_evaluator.rb', line 7

def symbols
  @symbols
end

Instance Method Details

#call(object) ⇒ Object

Evaluates the symbols in sequence starting within the context of object.



19
20
21
22
23
24
25
# File 'lib/jsapi/meta/callable/symbol_sequence_evaluator.rb', line 19

def call(object)
  @callables.each do |callable|
    object = callable.call(object)
    break if object.nil?
  end
  object
end

#inspectObject

:nodoc:



14
15
16
# File 'lib/jsapi/meta/callable/symbol_sequence_evaluator.rb', line 14

def inspect # :nodoc:
  "#<#{self.class.name} #{@symbols.inspect}>"
end