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::ConstList, Parts::Resource::ConstTypes, Parts::Resource::IRIDecode, Parts::Resource::IRIDecodeTable, Parts::Resource::IRIEncode, Parts::Resource::IRIEncodeTable, Parts::Resource::IRIHeader, Parts::Resource::LabelProperty

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

Attributes inherited from BasicTypes::Object

#label

Attributes included from Parts::Resource

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

Instance Method Summary collapse

Methods included from Parts::Resource

#[], #^, _abbreviation_to_iri, _decode, _encode, _extract_prefix, _instance, _instantiate, _parse, _path_with_prefix, _replace_tags, _setup_, _setup_info, _simplify_path, base_uri, #each, #enum_for, #hierarchy, #include?, #included?, #iri, #leaf?, #m17n, #map, #parent, #registered?, root_dir

Methods included from Parts::Resource::Pool

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

Methods included from Parts::Resource::Synchronize

#synchronize

Constructor Details

#initialize(position) ⇒ Instant

オブジェクトの生成

Parameters:



243
244
245
246
247
# File 'lib/when_exe/tmobjects.rb', line 243

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) に委譲する

その他のメソッド



257
258
259
260
261
262
263
264
265
266
# File 'lib/when_exe/tmobjects.rb', line 257

def method_missing(name, *args, &block)
  self.class.module_eval %Q{
    def #{name}(*args, &block)
      list = args.map {|arg| arg.kind_of?(self.class) ? arg.position : arg}
      @position.send("#{name}", *list, &block)
    end
  } unless When::Parts::MethodCash.escape(name)
  list = args.map {|arg| arg.kind_of?(self.class) ? arg.position : arg}
  @position.send(name, *list, &block)
end

Instance Attribute Details

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

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

Returns:



169
170
171
# File 'lib/when_exe/tmobjects.rb', line 169

def begun_by
  @begun_by
end

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

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

Returns:



176
177
178
# File 'lib/when_exe/tmobjects.rb', line 176

def ended_by
  @ended_by
end

#positionWhen::TM::Position (readonly)

この瞬間の時間位置

Returns:



163
164
165
# File 'lib/when_exe/tmobjects.rb', line 163

def position
  @position
end

#topologyWhen::TM::Node (readonly)

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

Returns:



183
184
185
# File 'lib/when_exe/tmobjects.rb', line 183

def topology
  @topology
end

Instance Method Details

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

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

Parameters:

Returns:



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

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:



189
190
191
# File 'lib/when_exe/tmobjects.rb', line 189

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

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

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

Parameters:

Returns:



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

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