Class: When::TM::Coordinate

Inherits:
TemporalPosition show all
Defined in:
lib/when_exe/tmposition.rb

Overview

時間座標 - 単一の時間間隔によって定義する連続な間隔尺度を基礎とする

see gml schema

Direct Known Subclasses

JulianDate

Constant Summary

Constants inherited from TemporalPosition

TemporalPosition::AMPM, TemporalPosition::Format, TemporalPosition::HashProperty

Constants included from Coordinates

Coordinates::Bahai, Coordinates::Common, Coordinates::DefaultDateIndices, Coordinates::DefaultDayIndex, Coordinates::DefaultTimeIndices, Coordinates::Indian, Coordinates::Iranian, Coordinates::Javanese, Coordinates::MATCH, Coordinates::Mayan, Coordinates::PERIOD, Coordinates::PERIOD_NAME, Coordinates::PRECISION, Coordinates::PRECISION_NAME, Coordinates::Tibetan, Coordinates::VALUE, Coordinates::Yi

Constants included from When

CENTURY, DAY, DECADE, EUCJP, HOUR, MINUTE, MONTH, MinusInfinity, P1D, P1M, P1W, P1Y, PT1H, PT1M, PT1S, PlusInfinity, RootDir, SECOND, STRING, SYSTEM, SourceURI, When::TimeValue, UTF8, VERSION, W31J, WEEK, YEAR

Constants included from Parts::Resource

Parts::Resource::ConstList, Parts::Resource::ConstTypes, Parts::Resource::IRIHeader, Parts::Resource::LabelProperty

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 inherited from TemporalPosition

#events, #frame, #indeterminated_position, #location, #options, #precision, #query, #trans

Attributes included from Parts::Resource

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TemporalPosition

#+@, #<=>, #==, #[], #^, #_attr, _instance, #_notes, _options, _setup_, _setup_info, #_term, #_to_h, #_to_s, _verify, #calendar_name, #caret_frame, #clock_name, #copy, #dynamical_time, #floor, format, #has_next?, #has_time?, #include?, #inspect, #is?, #month_included, #note?, #notes, #period, #prev, #rate_of_clock, #reference_label, #scan, #strftime, #succ, #time_standard, #to_clock_time, #to_date, #to_date_time, #to_f, #to_i, #to_m17n, #to_residue, #to_s, #to_time, #week_included, #year_included

Methods included from Coordinates

to_deg, to_deg_225, to_dms

Methods included from When

Calendar, CalendarEra, CalendarNote, Clock, Duration, Index, Location, M17n, MonthName, Pair, Residue, Resource, TemporalPosition, Wikipedia, _const_missing, _define_common_calendar_types, _setup_, _setup_info, at, client, column, config, const_missing, era, free_conv, m17n, now, server, today, when?

Methods included from TemporalPosition::Conversion

#julian_date, #tm_pos

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, #next, #parent, #prev, #registered?, root_dir

Methods included from Parts::Resource::Pool

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

Methods included from Parts::Resource::Synchronize

#synchronize

Constructor Details

#initialize(universal_time, options = {}) ⇒ Coordinate

オブジェクトの生成

Parameters:

  • universal_time (Numeric)

    内部時間による時間座標値

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

    下記の通り

Options Hash (options):



1171
1172
1173
1174
# File 'lib/when_exe/tmposition.rb', line 1171

def initialize(universal_time, options={})
  super(options)
  @universal_time = universal_time
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class When::TM::TemporalPosition

Instance Attribute Details

#universal_timeNumeric Also known as: coordinateValue

内部時間による時間座標値

Returns:



1129
1130
1131
# File 'lib/when_exe/tmposition.rb', line 1129

def universal_time
  @universal_time
end

Class Method Details

.dynamical_time(dynamical_time, options = {}) ⇒ When::TM::Coordinate

外部時間によるオブジェクトの生成

Parameters:

  • dynamical_time (Numeric)

    外部時間による時間座標値

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

    下記の通り

Options Hash (options):

Returns:



1067
1068
1069
# File 'lib/when_exe/tmposition.rb', line 1067

def dynamical_time(dynamical_time, options={})
  universal_time(When.Resource(options[:time_standard] || 'UniversalTime', '_t:').from_dynamical_time(dynamical_time), options)
end

.new(time, options = {}) ⇒ When::TM::Coordinate

他種の時間位置によるオブジェクトの生成

Parameters:

Options Hash (options):

Returns:

Raises:

  • (TypeError)


1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
# File 'lib/when_exe/tmposition.rb', line 1081

def new(time, options={})
  options         = options.dup
  options[:frame] = Clock.get_clock_option(options)
  case time
  when Numeric
    options[:frame] ||= When::UTC unless time.kind_of?(Integer)
    universal_time    = (2*time - (2*JulianDate::JD19700101-1)) * Duration::DAY.to_i / 2.0
  when ClockTime
    options[:frame] ||= time.clock
    universal_time    = time.clk_time[0] + time.universal_time
  when ::Time
    options[:frame] ||= When.Clock(time.gmtoff)
    universal_time    = options[:frame].time_standard.from_time_object(time)
  when TimeValue
    options[:frame] ||= time.clock
    universal_time    = time.universal_time
  else
    if ::Object.const_defined?(:Date) && time.respond_to?(:ajd)
      case time
      when ::DateTime
        options[:frame] ||= When.Clock((time.offset * 86400).to_i)
        universal_time    = (2*time.ajd - (2*JulianDate::JD19700101-1)) * Duration::DAY.to_i / 2.0
      when ::Date
        universal_time    = JulianDate._d_to_t(time.jd)
        if options[:frame] && options[:frame].rate_of_clock != 1.0
          universal_time  = options[:frame].time_standard.from_dynamical_time(
                                         When::TimeStandard.to_dynamical_time(universal_time))
        end
      end
    end
  end
  raise TypeError, "Can't create #{self} from #{time.class}" unless universal_time
  universal_time(universal_time, options)
end

.universal_timeObject

内部時間によるオブジェクトの生成



1056
# File 'lib/when_exe/tmposition.rb', line 1056

alias :universal_time :new

Instance Method Details

#+(other) ⇒ When::TM::TemporalPosition

加算



1147
1148
1149
1150
# File 'lib/when_exe/tmposition.rb', line 1147

def +(other)
  other = other.to_interval_length if other.kind_of?(PeriodDuration)
  super(other)
end

#-(other) ⇒ When::TM::TemporalPosition, When::TM::IntervalLength

減算

Parameters:

Returns:



1159
1160
1161
1162
# File 'lib/when_exe/tmposition.rb', line 1159

def -(other)
  other = other.to_interval_length if other.kind_of?(PeriodDuration)
  super(other)
end