Class: Selene::ComponentBuilder
- Inherits:
-
Object
- Object
- Selene::ComponentBuilder
- Includes:
- ComponentRules
- Defined in:
- lib/selene/component_builder.rb
Direct Known Subclasses
AlarmBuilder, CalendarBuilder, DaylightSavingsTimeBuilder, EventBuilder, StandardTimeBuilder, TimeZoneBuilder
Constant Summary collapse
- REQUIRED_PROPERTIES =
[]
- DISTINCT_PROPERTIES =
[]
- EXCLUSIVE_PROPERTIES =
[]
Instance Attribute Summary collapse
-
#component ⇒ Object
Returns the value of attribute component.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
- #a_component_rules ⇒ Object
- #add(name, builder) ⇒ Object
-
#initialize ⇒ ComponentBuilder
constructor
A new instance of ComponentBuilder.
- #name(line) ⇒ Object
- #parse(line) ⇒ Object
- #valid? ⇒ Boolean
- #value(line) ⇒ Object
Methods included from ComponentRules
#component_rules, #property_rules
Constructor Details
#initialize ⇒ ComponentBuilder
Returns a new instance of ComponentBuilder.
16 17 18 19 20 21 |
# File 'lib/selene/component_builder.rb', line 16 def initialize @component = Hash.new { |component, property| component[property] = [] } @errors = [] @property_rules = property_rules(self) @component_rules = component_rules(self) end |
Instance Attribute Details
#component ⇒ Object
Returns the value of attribute component.
5 6 7 |
# File 'lib/selene/component_builder.rb', line 5 def component @component end |
#errors ⇒ Object
Returns the value of attribute errors.
5 6 7 |
# File 'lib/selene/component_builder.rb', line 5 def errors @errors end |
#parent ⇒ Object
Returns the value of attribute parent.
5 6 7 |
# File 'lib/selene/component_builder.rb', line 5 def parent @parent end |
Instance Method Details
#a_component_rules ⇒ Object
36 37 38 |
# File 'lib/selene/component_builder.rb', line 36 def a_component_rules @component_rules end |
#add(name, builder) ⇒ Object
11 12 13 14 |
# File 'lib/selene/component_builder.rb', line 11 def add(name, builder) @component[name.downcase] << builder.component builder.parent = self end |
#name(line) ⇒ Object
28 29 30 |
# File 'lib/selene/component_builder.rb', line 28 def name(line) line.name end |
#parse(line) ⇒ Object
23 24 25 26 |
# File 'lib/selene/component_builder.rb', line 23 def parse(line) return unless @property_rules.all? { |, rule| rule.call(name(line), line, ) } @component[name(line)] = value(line) end |
#valid? ⇒ Boolean
40 41 42 43 |
# File 'lib/selene/component_builder.rb', line 40 def valid? @component_rules.each { |, rule| rule.call() } @errors.empty? end |
#value(line) ⇒ Object
32 33 34 |
# File 'lib/selene/component_builder.rb', line 32 def value(line) line.value end |