Class: TimeScales::Frame::Base
- Inherits:
-
Object
- Object
- TimeScales::Frame::Base
show all
- Defined in:
- lib/time_scales/frame/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(*args) ⇒ Base
Returns a new instance of Base.
36
37
38
|
# File 'lib/time_scales/frame/base.rb', line 36
def initialize(*args)
_initialize args
end
|
Class Method Details
.&(time) ⇒ Object
22
23
24
25
26
27
|
# File 'lib/time_scales/frame/base.rb', line 22
def &(time)
part_values = parts.map { |part|
part & time
}
new( *part_values )
end
|
.outer_scope ⇒ Object
14
15
16
|
# File 'lib/time_scales/frame/base.rb', line 14
def outer_scope
parts.first.scope
end
|
.parts ⇒ Object
7
8
9
10
11
12
|
# File 'lib/time_scales/frame/base.rb', line 7
def parts
@parts ||=
_parts.
sort_by { |part| -part.scale }.
freeze
end
|
.precision ⇒ Object
18
19
20
|
# File 'lib/time_scales/frame/base.rb', line 18
def precision
parts.last.subdivision
end
|
Instance Method Details
#==(other) ⇒ Object
71
72
73
74
75
76
77
78
|
# 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) ⇒ Boolean
Symmetric, hash-key equality.
66
67
68
69
|
# File 'lib/time_scales/frame/base.rb', line 66
def eql?(other)
self.class == other.class &&
self._to_a == other._to_a
end
|
#hash ⇒ Object
80
81
82
|
# File 'lib/time_scales/frame/base.rb', line 80
def hash
@hash ||= self.class.hash ^ _to_a.hash
end
|
#outer_scope ⇒ Object
57
58
59
|
# File 'lib/time_scales/frame/base.rb', line 57
def outer_scope
self.class.outer_scope
end
|
#parts ⇒ Object
48
49
50
51
52
53
54
55
|
# 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 ⇒ Object
61
62
63
|
# File 'lib/time_scales/frame/base.rb', line 61
def precision
self.class.precision
end
|
#to_a ⇒ Object
84
85
86
|
# File 'lib/time_scales/frame/base.rb', line 84
def to_a
_to_a.dup
end
|
#to_time_scales_frame ⇒ Object
40
41
42
|
# File 'lib/time_scales/frame/base.rb', line 40
def to_time_scales_frame
self
end
|
#type ⇒ Object
44
45
46
|
# File 'lib/time_scales/frame/base.rb', line 44
def type
self.class
end
|