Class: TimeScales::Frame::PartDef

Inherits:
Object
  • Object
show all
Defined in:
lib/time_scales/frame/part_def.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#keyObject (readonly)

Returns the value of attribute key.



5
6
7
# File 'lib/time_scales/frame/part_def.rb', line 5

def key
  @key
end

#partObject (readonly)

Returns the value of attribute part.



5
6
7
# File 'lib/time_scales/frame/part_def.rb', line 5

def part
  @part
end

#valueObject (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

#scaleObject



12
13
14
# File 'lib/time_scales/frame/part_def.rb', line 12

def scale
  possible_parts.first.scale
end