Class: When::TM::Period
- Inherits:
-
GeometricPrimitive
- Object
- BasicTypes::Object
- Object
- Primitive
- GeometricPrimitive
- When::TM::Period
- Defined in:
- lib/when_exe/tmobjects.rb
Overview
期間 - 一次元幾何プリミティブ
see gml schema
Constant Summary collapse
- RELATIVE_POSITION =
{ RelativePosition::Contains => { RelativePosition::Before => RelativePosition::Overlaps, RelativePosition::EndedBy => RelativePosition::EndedBy, RelativePosition::Contains => RelativePosition::Contains }, RelativePosition::BegunBy => { RelativePosition::Before => RelativePosition::Begins, RelativePosition::EndedBy => RelativePosition::Equals, RelativePosition::Contains => RelativePosition::BegunBy }, RelativePosition::After => { RelativePosition::Before => RelativePosition::During, RelativePosition::EndedBy => RelativePosition::Ends, RelativePosition::Contains => RelativePosition::OverlappedBy } }
Constants included from Namespace
Namespace::DC, Namespace::DCQ, Namespace::DCT, Namespace::FOAF, Namespace::OWL, Namespace::RDF, Namespace::RDFC, Namespace::RDFS, Namespace::RSS, Namespace::XSD
Instance Attribute Summary collapse
-
#begin ⇒ When::TM::Instant
readonly
この期間が始まる瞬間 (relation - Beginning).
-
#end ⇒ When::TM::Instant
readonly
この期間が終わる瞬間 (relation - Ending).
-
#topology ⇒ When::TM::Edge
readonly
対応するエッジ (relation - Realization).
Attributes inherited from BasicTypes::Object
Attributes included from Parts::Resource
#child, #keys, #locale, #namespace
Instance Method Summary collapse
-
#distance(other) ⇒ When::TM::Duration
他のWhen::TM::GeometricPrimitiveとの時間位置の差の絶対値.
-
#initialize(begun, ended) ⇒ Period
constructor
オブジェクトの生成.
-
#length ⇒ When::TM::Duration
When::TM::GeometricPrimitive 自身の持続時間.
-
#relative_position(other) ⇒ When::TM::RelativePosition
(also: #relativePosition)
他のPrimitiveとの相対的な時間位置.
Methods included from Parts::Resource
#[], #^, _instance, _setup_, _setup_info, base_uri, #each, #enum_for, #hierarchy, #include?, #included?, #iri, #leaf?, #m17n, #map, #parent, #registered?, root_dir
Methods included from Parts::Resource::Pool
Constructor Details
#initialize(begun, ended) ⇒ Period
オブジェクトの生成
378 379 380 381 382 383 384 |
# File 'lib/when_exe/tmobjects.rb', line 378 def initialize(begun, ended) raise ArgumentError, 'Order mismatch: begun > ended' if begun > ended @begin = begun @end = ended @begin.begun_by << self @end.ended_by << self end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (private)
When::TM::Period で定義されていないメソッドは 処理を @begin (type: When::TM::Instant) に委譲する
その他のメソッド
394 395 396 397 398 399 400 401 |
# File 'lib/when_exe/tmobjects.rb', line 394 def method_missing(name, *args, &block) self.class.module_eval %Q{ def #{name}(*args, &block) @begin.send("#{name}", *args, &block) end } unless When::Parts::MethodCash.escape(name) @begin.send(name, *args, &block) end |
Instance Attribute Details
#begin ⇒ When::TM::Instant (readonly)
この期間が始まる瞬間 (relation - Beginning)
297 298 299 |
# File 'lib/when_exe/tmobjects.rb', line 297 def begin @begin end |
#end ⇒ When::TM::Instant (readonly)
この期間が終わる瞬間 (relation - Ending)
303 304 305 |
# File 'lib/when_exe/tmobjects.rb', line 303 def end @end end |
#topology ⇒ When::TM::Edge (readonly)
対応するエッジ (relation - Realization)
309 310 311 |
# File 'lib/when_exe/tmobjects.rb', line 309 def topology @topology end |
Instance Method Details
#distance(other) ⇒ When::TM::Duration
他のWhen::TM::GeometricPrimitiveとの時間位置の差の絶対値
325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/when_exe/tmobjects.rb', line 325 def distance(other) case other when Instant return other.distance(self) when Period verify = other.begin.position - self.end.position return verify if verify.sign >= 0 return [self.begin.position - other.end.position, When::TM::PeriodDuration.new(0,When::DAY)].max else raise TypeError, "The right operand should be Instant or Period" end end |
#length ⇒ When::TM::Duration
When::TM::GeometricPrimitive 自身の持続時間
315 316 317 |
# File 'lib/when_exe/tmobjects.rb', line 315 def length() @length ||= @end - @begin end |
#relative_position(other) ⇒ When::TM::RelativePosition Also known as: relativePosition
他のPrimitiveとの相対的な時間位置
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
# File 'lib/when_exe/tmobjects.rb', line 344 def relative_position(other) case other when Instant verify = self.end.position <=> other.position return RelativePosition::Before if verify < 0 return RelativePosition::EndedBy if verify == 0 verify = self.begin.position <=> other.position return RelativePosition::Contains if verify < 0 return RelativePosition::BegunBy if verify == 0 return RelativePosition::After when Period verify_b = relative_position(other.begin) case verify_b when RelativePosition::Before ; return RelativePosition::Before when RelativePosition::EndedBy ; return RelativePosition::Meets end verify_e = relative_position(other.end) case verify_e when RelativePosition::BegunBy ; return RelativePosition::MetBy when RelativePosition::After ; return RelativePosition::After else ; return RELATIVE_POSITION[verify_b][verify_e] end else raise TypeError, "The right operand should be Instant or Period" end end |