Class: When::Coordinates::MultiBorder

Inherits:
Border show all
Defined in:
lib/when_exe/coordinates.rb

Overview

日時要素の境界 - 年/日によって、異なる境界を使用する場合

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

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 Border

#_date_adjust

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class When::Parts::Resource

Instance Attribute Details

#bordersArray<When::Coordinates::Border> (readonly)

境界の配列



2260
2261
2262
# File 'lib/when_exe/coordinates.rb', line 2260

def borders
  @borders
end

Instance Method Details

#_adjust_epoch(date, frame = nil) ⇒ Array<Numeric>

境界の正規化

Parameters:

Returns:



2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
# File 'lib/when_exe/coordinates.rb', line 2298

def _adjust_epoch(date, frame=nil)
  @borders.each do |border|
    next unless date[0] >= border[:key]
    s_date  = date.dup
    e_date  = border[:border].border(date[0..0], frame)
    branch  = border[:border].behavior * 0
    branch += 1 if ((s_date[1..-1] <=> e_date[1..-1]) < 0)
    s_date[0] = When::Coordinates::Pair.new(+s_date[0]-branch, branch)
    return s_date
  end
  date
end

#behaviorNumeric

境界の振舞

Returns:

  • (Numeric)

    Pair(-1,+1) - 暦年/暦日が進む(境界が前年/日にあり、境界後が当年/日の扱いになる)

    Pair( 0, 0) - 暦年/暦日が戻る(境界が当年/日にあり、境界前が前年/日の扱いになる)



2271
2272
2273
# File 'lib/when_exe/coordinates.rb', line 2271

def behavior
  @borders[0][:border].behavior
end

#border(date = [], frame = nil) ⇒ Array<Numeric>

境界の取得

Parameters:

Returns:



2282
2283
2284
2285
2286
2287
2288
2289
# File 'lib/when_exe/coordinates.rb', line 2282

def border(date=[], frame=nil)
  last = date.length-1
  return @borders[0][:boder] if (last<0)
  @borders.each do |border|
    return border[:border].border(date, frame) if date[0] >= border[:key]
  end
  date[0..last]
end