Class: When::Coordinates::LeapSeconds
- Defined in:
- lib/when_exe/coordinates.rb
Overview
暦座標値
閏秒のある暦座標の値を表現する
Constant Summary
Constants inherited from Pair
Pair::DL0, Pair::DL1, Pair::DL2
Instance Attribute Summary collapse
-
#frac ⇒ Float
readonly
trunk の小数部.
-
#int ⇒ Integer
readonly
trunk の整数部.
-
#second ⇒ Numeric
readonly
閏秒の単位 / When::TM::Duration::SYSTEM.
Attributes inherited from Pair
Instance Method Summary collapse
-
#+(other) ⇒ When::Coordinates::LeapSeconds
加算.
-
#-(other) ⇒ When::Coordinates::LeapSeconds
減算.
-
#<=>(other) ⇒ Integer
比較.
-
#coerce(other) ⇒ Object
強制型変換.
-
#divmod(other) ⇒ When::Coordinates::LeapSeconds
商と剰余.
-
#initialize(trunk, branch, second) ⇒ LeapSeconds
constructor
オブジェクトの生成.
-
#to_s(zero = '') ⇒ String
文字列化.
Methods inherited from Pair
#%, #*, #+@, #-@, _de_pair, _en_number, _en_pair, _en_pair_array, _en_pair_date_time, _force_pair, _format, #_to_hash_value, #inspect
Methods inherited from Numeric
#clock, #to_day_of_week, #to_month_name, #to_pair, #unit_duration, #unit_interval_length, #unit_period_duration
Methods included from TM::TemporalPosition::Conversion
Constructor Details
#initialize(trunk, branch, second) ⇒ LeapSeconds
オブジェクトの生成
1239 1240 1241 1242 1243 |
# File 'lib/when_exe/coordinates.rb', line 1239 def initialize(trunk, branch, second) @second = second @int, @frac = trunk.divmod(second) super(trunk, branch) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class When::Coordinates::Pair
Instance Attribute Details
#frac ⇒ Float (readonly)
trunk の小数部
1166 1167 1168 |
# File 'lib/when_exe/coordinates.rb', line 1166 def frac @frac end |
#int ⇒ Integer (readonly)
trunk の整数部
1159 1160 1161 |
# File 'lib/when_exe/coordinates.rb', line 1159 def int @int end |
#second ⇒ Numeric (readonly)
閏秒の単位 / When::TM::Duration::SYSTEM
1152 1153 1154 |
# File 'lib/when_exe/coordinates.rb', line 1152 def second @second end |
Instance Method Details
#+(other) ⇒ When::Coordinates::LeapSeconds
加算
1175 1176 1177 1178 |
# File 'lib/when_exe/coordinates.rb', line 1175 def +(other) return self.class.new(@trunk + +other, @branch, @second) unless other.kind_of?(self.class) return self.class.new(@trunk + other.trunk, @branch + other.branch, @second) end |
#-(other) ⇒ When::Coordinates::LeapSeconds
減算
1187 1188 1189 1190 |
# File 'lib/when_exe/coordinates.rb', line 1187 def -(other) return self.class.new(@trunk - +other, @branch, @second) unless other.kind_of?(self.class) return self.class.new(@trunk - other.trunk, @branch - other.branch, @second) end |
#<=>(other) ⇒ Integer
比較
1211 1212 1213 1214 1215 |
# File 'lib/when_exe/coordinates.rb', line 1211 def <=>(other) other = self.class.new(+other, 0, @second) unless other.kind_of?(self.class) raise ArgumentError, "length of unit 'second' mismatch" unless @second == other.second (@int <=> other.int).nonzero? || (@branch <=> other.branch).nonzero? || (@frac <=> other.frac) end |
#coerce(other) ⇒ Object
強制型変換
1229 1230 1231 |
# File 'lib/when_exe/coordinates.rb', line 1229 def coerce(other) [self.class.new(other, 0, @second), self] end |
#divmod(other) ⇒ When::Coordinates::LeapSeconds
商と剰余
1199 1200 1201 1202 |
# File 'lib/when_exe/coordinates.rb', line 1199 def divmod(other) div, mod = @trunk.divmod(other) return div, self.class.new(mod, @branch, @second) end |