Class: Fathom::ValueDescription

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*nodes, &block) ⇒ ValueDescription

Returns a new instance of ValueDescription.



17
18
19
20
# File 'lib/fathom/value_description.rb', line 17

def initialize(*nodes, &block)
  assert_nodes(nodes)
  @process_block = block if block_given?
end

Instance Attribute Details

#last_processObject (readonly)

Returns the value of attribute last_process.



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

def last_process
  @last_process
end

#nodesObject (readonly)

Returns the value of attribute nodes.



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

def nodes
  @nodes
end

Class Method Details

.define_node_accessor(node, method = :node) ⇒ Object

Returns a simple accessor for the node, so that the value description works a little like an OpenStruct.



7
8
9
10
11
# File 'lib/fathom/value_description.rb', line 7

def define_node_accessor(node, method = :node)
  define_method(node.name_sym) do
    node.send(method)
  end
end

Instance Method Details

#add_node(node, method = :rand) ⇒ Object



22
23
24
# File 'lib/fathom/value_description.rb', line 22

def add_node(node, method = :rand)
  assert_node(node, method)
end

#processObject



26
27
28
29
# File 'lib/fathom/value_description.rb', line 26

def process
  prepare_process
  @process_block ? @process_block.call(@last_process) : default_process(@last_process)
end