Class: TimeScales::Frame::PartDef
- Inherits:
-
Object
- Object
- TimeScales::Frame::PartDef
- Defined in:
- lib/time_scales/frame/part_def.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#part ⇒ Object
readonly
Returns the value of attribute part.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #component_of!(scope) ⇒ Object
-
#initialize(key, value = nil) ⇒ PartDef
constructor
A new instance of PartDef.
- #outer_scope! ⇒ Object
- #scale ⇒ Object
Constructor Details
#initialize(key, value = nil) ⇒ PartDef
Returns a new instance of PartDef.
7 8 9 10 |
# File 'lib/time_scales/frame/part_def.rb', line 7 def initialize(key, value=nil) @key = key @value = value end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
5 6 7 |
# File 'lib/time_scales/frame/part_def.rb', line 5 def key @key end |
#part ⇒ Object (readonly)
Returns the value of attribute part.
5 6 7 |
# File 'lib/time_scales/frame/part_def.rb', line 5 def part @part end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/time_scales/frame/part_def.rb', line 5 def value @value end |
Instance Method Details
#component_of!(scope) ⇒ Object
22 23 24 25 26 |
# File 'lib/time_scales/frame/part_def.rb', line 22 def component_of!(scope) @part = possible_parts.detect { |part| scope.subdivision === part.scope } end |
#outer_scope! ⇒ Object
16 17 18 19 20 |
# File 'lib/time_scales/frame/part_def.rb', line 16 def outer_scope! @part = possible_parts.length == 1 ? possible_parts.first : possible_parts.detect { |part| part.default_for_unit? } end |
#scale ⇒ Object
12 13 14 |
# File 'lib/time_scales/frame/part_def.rb', line 12 def scale possible_parts.first.scale end |