Class: ERBB::Result

Inherits:
String
  • Object
show all
Defined in:
lib/erbb/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str, named_blocks, opts = {}) ⇒ Result

Returns a new instance of Result.



13
14
15
16
# File 'lib/erbb/result.rb', line 13

def initialize(str, named_blocks, opts = {})
  super(str, *opts)
  @named_blocks = Hash[named_blocks.map { |k,v| [k.to_sym, v] }]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/erbb/result.rb', line 5

def method_missing(method_name)
  if named_blocks.key?(method_name)
    named_blocks[method_name]
  else
    super
  end
end

Instance Attribute Details

#named_blocksObject (readonly)

Returns the value of attribute named_blocks.



3
4
5
# File 'lib/erbb/result.rb', line 3

def named_blocks
  @named_blocks
end