Class: When::TM::Instant

Inherits:
GeometricPrimitive show all
Defined in:
lib/when_exe/tmobjects.rb

Overview

瞬間 - 零次元幾何プリミティブ

see gml schema

Constant Summary

Constants included from Parts::Resource

Parts::Resource::LabelProperty, Parts::Resource::Prefix, Parts::Resource::PrefixIndex, Parts::Resource::PrefixKeys, Parts::Resource::PrefixValues

Instance Attribute Summary collapse

Attributes inherited from BasicTypes::Object

#label

Attributes included from Parts::Resource

#_pool, #child, #keys, #locale, #namespace

Instance Method Summary collapse

Methods inherited from BasicTypes::Object

#tap

Methods included from Parts::Resource

#[], #^, _extract_prefix, _instance, _parse, _path_with_prefix, #each, #enum_for, #hierarchy, #include?, #included?, #iri, #leaf?, #m17n, #map, #next, #parent, #prev, #registered?

Methods included from Parts::Resource::Pool

#[], #[]=, #_pool, #_setup_, #pool_keys

Methods included from Parts::Resource::Synchronize

#synchronize

Constructor Details

#initialize(position) ⇒ Instant

オブジェクトの生成

Parameters:



241
242
243
244
245
# File 'lib/when_exe/tmobjects.rb', line 241

def initialize(position)
  @position = position
  @begun_by = []
  @ended_by = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object (private)

Note:

When::TM::Instant で定義されていないメソッドは処理を @position (type: When::TM::Position) に委譲する

その他のメソッド



255
256
257
# File 'lib/when_exe/tmobjects.rb', line 255

def method_missing(name, *args, &block)
  @position.send(name.to_sym, *args, &block)
end

Instance Attribute Details

#begun_byArray<When::TM::Period> (readonly) Also known as: begunBy

この瞬間を始まりとする期間 (relation - Beginning)

Returns:



167
168
169
# File 'lib/when_exe/tmobjects.rb', line 167

def begun_by
  @begun_by
end

#ended_byArray<When::TM::Period> (readonly) Also known as: endedBy

この瞬間を終わりとする期間 (relation - Ending)

Returns:



174
175
176
# File 'lib/when_exe/tmobjects.rb', line 174

def ended_by
  @ended_by
end

#positionWhen::TM::Position (readonly)

この瞬間の時間位置

Returns:



161
162
163
# File 'lib/when_exe/tmobjects.rb', line 161

def position
  @position
end

#topologyWhen::TM::Node (readonly)

対応するノード (relation - Realization)

Returns:



181
182
183
# File 'lib/when_exe/tmobjects.rb', line 181

def topology
  @topology
end

Instance Method Details

#distance(other) ⇒ When::TM::Duration

他のWhen::TM::GeometricPrimitiveとの時間位置の差の絶対値

Parameters:

Returns:



197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/when_exe/tmobjects.rb', line 197

def distance(other)
  case other
  when Instant
    return (self.position - other.position).abs
  when Period
    verify = other.begin.position - self.position
    return verify if verify.sign >= 0
    return [self.position - other.end.position, When::TM::PeriodDuration.new(0,When::DAY)].max
  else
    raise TypeError, "The right operand should be When::TM::Instant or When::TM::Period"
  end
end

#lengthWhen::TM::Duration

When::TM::GeometricPrimitive 自身の持続時間

Returns:



187
188
189
# File 'lib/when_exe/tmobjects.rb', line 187

def length()
  return When.Duration(0)
end

#relative_position(other) ⇒ When::TM::RelativePosition Also known as: relativePosition

他のWhen::TM::Primitiveとの相対的な時間位置

Parameters:

Returns:



216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/when_exe/tmobjects.rb', line 216

def relative_position(other)
  case other
  when Instant
    verify = self.position <=> other.position
    return RelativePosition::Before if verify <  0
    return RelativePosition::Equals if verify == 0
    return RelativePosition::After
  when Period
    verify = self.position <=> other.begin.position
    return RelativePosition::Before if verify <  0
    return RelativePosition::Begins if verify == 0
    verify = self.position <=> other.end.position
    return RelativePosition::During if verify <  0
    return RelativePosition::Ends   if verify == 0
    return RelativePosition::After
  else
    raise TypeError, "The right operand should be When::TM::Instant or When::TM::Period"
  end
end