Class: When::TM::Position

Inherits:
Object
  • Object
show all
Includes:
Parts::Resource, IndeterminateValue
Defined in:
lib/when_exe/tmposition.rb

Overview

Constant Summary collapse

HashProperty =
[:indeterminated_position, :frame,
[:precision, When::SYSTEM], :events, :options, :trans, :query,
:location, [:time_standard, When::TimeStandard::UniversalTime], [:rate_of_clock, 1.0]]

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

Constants included from IndeterminateValue

IndeterminateValue::After, IndeterminateValue::Before, IndeterminateValue::I, IndeterminateValue::Max, IndeterminateValue::Min, IndeterminateValue::Now, IndeterminateValue::S, IndeterminateValue::Unknown

Instance Attribute Summary collapse

Attributes included from Parts::Resource

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

Class Method Summary collapse

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(specification, options = {}) ⇒ Position

Note:

specification が String 以外の場合、そのオブジェクトの代表的な日時 (When::TM::CalendarEra#reference_dateなど)により解釈する

オブジェクトの生成

Parameters:

  • specification (String)

    When.exe Standard Representation として解釈して生成する

  • options (Hash) (defaults to: {})

    暦法や時法などの指定 see TemporalPosition._instance



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/when_exe/tmposition.rb', line 107

def initialize(specification, options={})

  case specification
  when String
    @date_time8601 = specification
    @any_other     = TemporalPosition._instance(specification, options)
  when Position
    @date_time8601 = specification.date_time8601
    @any_other     = specification.any_other
    return
  else
    @any_other     = specification
  end

  klass   = specification.class
  message = "Irregal specification type: #{klass}"

  case specification
  when CalDate                ; @date_time8601 = When::BasicTypes::Date.new(specification.to_s)
  when ClockTime              ; @date_time8601 = When::BasicTypes::Time.new(specification.to_s)
  when TemporalPosition       ; @date_time8601 = When::BasicTypes::DateTime.new(specification.to_s)
  when CalendarEra            ; @date_time8601 = When::BasicTypes::Date.new(specification.reference_date.to_s)
  when OrdinalEra             ; @date_time8601 = When::BasicTypes::Date.new(specification.begin.to_s)
  when When::BasicTypes::Date ; raise TypeError, message unless klass == CalDate
  when When::BasicTypes::Time ; raise TypeError, message unless klass == ClockTime
  when String                 ;
  else                        ; raise TypeError, message
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

Note:

When::TM::Position で定義されていないメソッドは 処理を @date_time8601 (type: When::BasicTypes::DateTime) または @any_other (type: When::TM::TemporalPosition) に委譲する (両方ともに有効なメソッドは@any_otherを優先する)

その他のメソッド



149
150
151
152
153
154
155
156
157
158
159
# File 'lib/when_exe/tmposition.rb', line 149

def method_missing(name, *args, &block)
  return _method_missing(name, *args, &block) if When::Parts::MethodCash::Escape.key?(name)
  self.class.module_eval %Q{
    def #{name}(*args, &block)
      union = @any_other.respond_to?("#{name}") ? @any_other : @date_time8601
      union.send("#{name}", *args, &block)
    end
  } unless When::Parts::MethodCash.escape(name)
  union = @any_other.respond_to?(name) ? @any_other : @date_time8601
  union.send(name, *args, &block)
end

Instance Attribute Details

#any_otherWhen::TM::TemporalPosition (readonly)

時間位置



73
74
75
# File 'lib/when_exe/tmposition.rb', line 73

def any_other
  @any_other
end

#date_time8601When::BasicTypes::DateTime (readonly) Also known as: dateTime8601

代表文字列



66
67
68
# File 'lib/when_exe/tmposition.rb', line 66

def date_time8601
  @date_time8601
end

Class Method Details

.any_other(position, options = {}) ⇒ When::TM::TemporalPosition

諸々のオブジェクトから When::TM::TemporalPosition を取り出す

Parameters:

Returns:



88
89
90
91
92
93
94
95
# File 'lib/when_exe/tmposition.rb', line 88

def self.any_other(position, options={})
  case position
  when TemporalPosition              ; position
  when Position                      ; position.any_other
  when When::Parts::GeometricComplex ; position.first
  else ; When.Calendar(options[:frame] || 'Gregorian').jul_trans(position, options) || position
  end
end

Instance Method Details

#anyOtherWhen::TM::TemporalPosition

時間位置



74
75
76
# File 'lib/when_exe/tmposition.rb', line 74

def any_other
  @any_other
end