Class: VectorSpace::ComponentReflection
- Inherits:
-
Object
- Object
- VectorSpace::ComponentReflection
- Defined in:
- lib/vector_space/component_reflection.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#component ⇒ Object
readonly
Returns the value of attribute component.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #getter ⇒ Object
-
#initialize(component, options = {}) ⇒ ComponentReflection
constructor
A new instance of ComponentReflection.
- #to_s ⇒ Object
- #value(value) ⇒ Object
Constructor Details
#initialize(component, options = {}) ⇒ ComponentReflection
Returns a new instance of ComponentReflection.
3 4 5 |
# File 'lib/vector_space/component_reflection.rb', line 3 def initialize(component, = {}) @component, @options = component, end |
Instance Attribute Details
#component ⇒ Object (readonly)
Returns the value of attribute component.
11 12 13 |
# File 'lib/vector_space/component_reflection.rb', line 11 def component @component end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/vector_space/component_reflection.rb', line 11 def @options end |
Instance Method Details
#getter ⇒ Object
13 14 15 |
# File 'lib/vector_space/component_reflection.rb', line 13 def getter [:getter] || component.to_sym end |
#to_s ⇒ Object
7 8 9 |
# File 'lib/vector_space/component_reflection.rb', line 7 def to_s "#{component} component (#{default.class})" end |
#value(value) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/vector_space/component_reflection.rb', line 17 def value(value) value ||= default if [:coerce] [:coerce].to_proc.call(value) else value end end |