Class: Fathom::ValueDescription
- Inherits:
-
Object
- Object
- Fathom::ValueDescription
- Defined in:
- lib/fathom/value_description.rb
Instance Attribute Summary collapse
-
#last_process ⇒ Object
readonly
Returns the value of attribute last_process.
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Class Method Summary collapse
-
.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.
Instance Method Summary collapse
- #add_node(node, method = :rand) ⇒ Object
-
#initialize(*nodes, &block) ⇒ ValueDescription
constructor
A new instance of ValueDescription.
- #process ⇒ Object
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_process ⇒ Object (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 |
#nodes ⇒ Object (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 |
#process ⇒ Object
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 |