class TimeScales::Frame::Base
Public Class Methods
&(time)
click to toggle source
# File lib/time_scales/frame/base.rb, line 22 def &(time) part_values = parts.map { |part| part & time } new( *part_values ) end
new(*args)
click to toggle source
# File lib/time_scales/frame/base.rb, line 36 def initialize(*args) _initialize args end
outer_scope()
click to toggle source
# File lib/time_scales/frame/base.rb, line 14 def outer_scope parts.first.scope end
parts()
click to toggle source
# File lib/time_scales/frame/base.rb, line 7 def parts @parts ||= _parts. sort_by { |part| -part.scale }. freeze end
precision()
click to toggle source
# File lib/time_scales/frame/base.rb, line 18 def precision parts.last.subdivision end
Private Class Methods
_parts()
click to toggle source
# File lib/time_scales/frame/base.rb, line 31 def _parts [] end
Public Instance Methods
==(other)
click to toggle source
# File lib/time_scales/frame/base.rb, line 71 def ==(other) return true if eql?( other ) return false unless other.respond_to?( :to_time_scales_frame ) other = other.to_time_scales_frame other.outer_scope == outer_scope && other.precision == precision && other.begin_time_struct == begin_time_struct end
eql?(other)
click to toggle source
Symmetric, hash-key equality.
# File lib/time_scales/frame/base.rb, line 66 def eql?(other) self.class == other.class && self._to_a == other._to_a end
hash()
click to toggle source
# File lib/time_scales/frame/base.rb, line 80 def hash @hash ||= self.class.hash ^ _to_a.hash end
outer_scope()
click to toggle source
# File lib/time_scales/frame/base.rb, line 57 def outer_scope self.class.outer_scope end
parts()
click to toggle source
# File lib/time_scales/frame/base.rb, line 48 def parts @parts ||= Hash[ self.class.parts.map { |part| [ part.symbol, send(part.symbol) ] } ] @parts.dup end
precision()
click to toggle source
# File lib/time_scales/frame/base.rb, line 61 def precision self.class.precision end
to_a()
click to toggle source
# File lib/time_scales/frame/base.rb, line 84 def to_a _to_a.dup end
to_time_scales_frame()
click to toggle source
# File lib/time_scales/frame/base.rb, line 40 def to_time_scales_frame self end
type()
click to toggle source
# File lib/time_scales/frame/base.rb, line 44 def type self.class end
Protected Instance Methods
_to_a()
click to toggle source
# File lib/time_scales/frame/base.rb, line 90 def _to_a @to_a ||= self.class.parts.map{ |part| send( part.symbol ) }.freeze end
begin_time_struct()
click to toggle source
# File lib/time_scales/frame/base.rb, line 96 def begin_time_struct @begin_time = begin struct = TimeStruct.new prepare_time_struct struct struct.normalize struct.freeze end end
Private Instance Methods
_initialize(args_array)
click to toggle source
# File lib/time_scales/frame/base.rb, line 107 def _initialize(args_array) #stub end
ensure_fixnum(value)
click to toggle source
# File lib/time_scales/frame/base.rb, line 111 def ensure_fixnum(value) return value if Fixnum === value raise ArgumentError, "Time part value must be of Fixnum type (a numeric integer)" end
prepare_time_struct(struct)
click to toggle source
# File lib/time_scales/frame/base.rb, line 116 def prepare_time_struct(struct) # stub end