Class: Iba::Combinator

Inherits:
Object
  • Object
show all
Defined in:
lib/iba.rb

Instance Method Summary collapse

Constructor Details

#initialize(&blk) ⇒ Combinator

Returns a new instance of Combinator.



7
8
9
# File 'lib/iba.rb', line 7

def initialize(&blk)
  @block = blk
end

Instance Method Details

#analyseObject



23
24
25
26
27
28
# File 'lib/iba.rb', line 23

def analyse
  str = +"#{self} is #{call.inspect}"
  sub = expression._display_subexpressions(@block.binding)
  str << "\n#{sub}" if sub
  str
end

#callObject



11
12
13
# File 'lib/iba.rb', line 11

def call
  @block.call
end

#expressionObject



19
20
21
# File 'lib/iba.rb', line 19

def expression
  @expression ||= EmptyExpression.new._parse(&@block)
end

#to_sObject



15
16
17
# File 'lib/iba.rb', line 15

def to_s
  expression._to_s
end