Class: AdfBuilder::Nodes::Timeframe
- Defined in:
- lib/adf_builder/nodes/customer.rb
Instance Attribute Summary
Attributes inherited from Node
#attributes, #children, #tag_name, #value
Instance Method Summary collapse
- #description(value) ⇒ Object
- #earliestdate(value) ⇒ Object
-
#initialize ⇒ Timeframe
constructor
A new instance of Timeframe.
- #latestdate(value) ⇒ Object
- #validate! ⇒ Object
Methods inherited from Node
#add_child, #method_missing, #remove_children, #respond_to_missing?, #to_xml
Methods included from Validations
Constructor Details
#initialize ⇒ Timeframe
Returns a new instance of Timeframe.
39 40 41 42 |
# File 'lib/adf_builder/nodes/customer.rb', line 39 def initialize super @tag_name = :timeframe end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class AdfBuilder::Nodes::Node
Instance Method Details
#description(value) ⇒ Object
52 53 54 55 |
# File 'lib/adf_builder/nodes/customer.rb', line 52 def description(value) remove_children(:description) add_child(GenericNode.new(:description, {}, value)) end |
#earliestdate(value) ⇒ Object
57 58 59 60 61 |
# File 'lib/adf_builder/nodes/customer.rb', line 57 def earliestdate(value) validate_iso8601(value) remove_children(:earliestdate) add_child(GenericNode.new(:earliestdate, {}, value)) end |
#latestdate(value) ⇒ Object
63 64 65 66 67 |
# File 'lib/adf_builder/nodes/customer.rb', line 63 def latestdate(value) validate_iso8601(value) remove_children(:latestdate) add_child(GenericNode.new(:latestdate, {}, value)) end |
#validate! ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/adf_builder/nodes/customer.rb', line 44 def validate! super # If timeframe is present, earliestdate or latestdate is required return if @children.any? { |c| %i[earliestdate latestdate].include?(c.tag_name) } raise AdfBuilder::Error, "Timeframe must have at least one of earliestdate or latestdate" end |