In Files

Parent

Included Modules

Class Index [+]

Quicksearch

When::Parts::GeometricComplex

任意個の端点から構成する Range の subclass

Attributes

reverse[R]

範囲の反転

  type : Boolean
    true  - 反転する
    false - 反転しない

  無限の過去(-Infinity)を範囲に含むか否かと同値である
node[R]

When::Parts::GeometricComplex を構成する端点の Array

  type : [[Comparable, Boolean]]
    Comparable - 端点
    Boolean
      @reverse == true の場合
        true  - 範囲に含まない
        false - 範囲に含む
      @reverse == false の場合
        true  - 範囲に含む
        false - 範囲に含まない
        example [[3,true],[4,false]] は Range(3...4)に対応する

Public Class Methods

new(*args) click to toggle source

オブジェクトの生成

  引数パターン 1
    range    : Range

  引数パターン 2
    point    : Comparable
      Range (point..point) と同じ

  引数パターン 3
    first    : Comparable
    last     : Comparable
      Range (first...last) と同じ

  引数パターン 4
    first    : Comparable
    duration : When::TM::Duration
      Range (first...(first+duration)) と同じ

  引数パターン 5
    other    : When::Parts::GeometricComplex
      コピーもとの When::Parts::GeometricComplex

  引数パターン 6
    node     : [[Comparable, Boolean]]
      Comparable - 端点
      Boolean
        reverse == true の場合
          true  - 範囲に含まない
          false - 範囲に含む
        reverse == false の場合
          true  - 範囲に含む
          false - 範囲に含まない

  すべてのパターンに共通の最終引数
    reverse  : Boolean
      true  - 反転する
      false - 反転しない(デフォルト)
      # File when/parts.rb, line 1591
1591:     def initialize(*args)
1592: 
1593:       @reverse = (args[1]==true || args[1]==false) ? args.pop : false
1594: 
1595:       case args[0]
1596:       when GeometricComplex
1597:         @node     = args[0].node
1598:         @reverse ^= args[0].reverse
1599:         super(self.first, self.last, exclude_end?) if self.first && self.last
1600:         return
1601: 
1602:       when Array
1603:         @node = args[0]
1604:         super(self.first, self.last, exclude_end?) if self.first && self.last
1605:         return
1606: 
1607:       when Range
1608:         first = [args[0].first, true]
1609:         last  = [args[0].last, !args[0].exclude_end?]
1610: 
1611:       when Comparable
1612:         first, last, rest = args
1613:         raise ArgumentError, "Too many argument: #{rest}" if rest
1614:         first = [first, true]
1615:         case last
1616:         when Comparable         ; last = [last, false]
1617:         when When::TM::Duration ; last = [first[0] + last, false]
1618:         when nil                ; last = first
1619:         else ; raise TypeError, "Irregal GeometricComplex Type for last element: #{last.class}"
1620:         end
1621: 
1622:       when nil ;
1623:       else ; raise TypeError, "Irregal GeometricComplex Type: #{first.class}"
1624:       end
1625: 
1626:       first, last = last, first if (first && last && first[0] > last[0])
1627:       @node = []
1628:       @node << first if first
1629:       @node << last  if last
1630:       super(self.first, self.last, exclude_end?) if first && last
1631:     end

Public Instance Methods

-@() click to toggle source

範囲を反転する

      # File when/parts.rb, line 1448
1448:     def -@
1449:       GeometricComplex.new(self, true)
1450:     end
<=>(other) click to toggle source

最小の端点と other を比較する

  other   : Comparable
    比較対象

  returns : Integer
    比較結果を 負, 0, 正の値で返す
      # File when/parts.rb, line 1460
1460:     def <=>(other)
1461:       first <=> other
1462:     end
===(other) click to toggle source
Alias for: include?
begin(default=nil) click to toggle source
Alias for: first
end(default=nil) click to toggle source
Alias for: last
exclude_end?(index=-1) click to toggle source

端点が範囲に含まれるか?

  index   : Integer
    端点の番号(デフォルト : -1 - 最大の端点)

  returns : Boolean
    true  - 含まれる
    false - 含まれない
      # File when/parts.rb, line 1433
1433:     def exclude_end?(index=1)
1434:       (@node.length==0) ? nil : !@node[index][1] ^ @reverse
1435:     end
first(default=nil) click to toggle source

最小の端点

  default : 端点が-∞の場合に返すべき値(指定がなければ nil)

  returns : Comparable
    最小の端点

    含むか否かに関わらず、最小の端点を返す
    default が指定されているが有効な区間がない場合、nil を返す
      # File when/parts.rb, line 1393
1393:     def first(default=nil)
1394:       return (@node.length==0) ? nil : @node[0][0] unless default # 互換性
1395:       if reverse
1396:         return default
1397:       else
1398:         (@node.length==0) ? nil : @node[0][0]
1399:       end
1400:     end
Also aliased as: begin
include?(other) click to toggle source

範囲に含まれるか?

  other   : Comparable
    判断する Comparable

  returns : Boolean
    true  - 範囲に含まれる
    false - 範囲に含まれない

  制限事項
    When::TM::TopologicalComplex どうしの包含判定は、和集合がもとの範囲と等しいか
    で判断している。分解能が When::Coordinates::SYSTEM でない場合、論理的には等しい
    ものが、内部表現が異なるために等しくないとみなされる事があり、その場合 true で
    あるべきものを false と誤判断する。実行速度上の制約もあり、現時点では対策を行わ
    ない。
      # File when/parts.rb, line 1528
1528:     def include?(other)
1529:       if (other.kind_of?(Comparable) && !other.kind_of?(GeometricComplex))
1530:         return (_include_point?(other) != false)
1531:       else
1532:         other = GeometricComplex.new(other) unless other.kind_of?(GeometricComplex)
1533:         return _include_range?(other)
1534:       end
1535:     end
Also aliased as: ===
last(default=nil) click to toggle source

最大の端点

  default : 端点が+∞場合に返すべき値(指定がなければ nil)

  returns : Comparable
    最大の端点

    含むか否かに関わらず、最大の端点を返す
    default が指定されているが有効な区間がない場合、nil を返す
      # File when/parts.rb, line 1413
1413:     def last(default=nil)
1414:       return (@node.length==0) ? nil : @node[1][0] unless default # 互換性
1415:       if reverse
1416:         return (@node.length[0]==0) ? default : @node[1][0]
1417:       else
1418:         return nil if (@node.length==0)
1419:         return (@node.length[0]==1) ? default : @node[1][0]
1420:       end
1421:     end
Also aliased as: end
precision() click to toggle source

分解能

  returns : Integer
    最小の端点の分解能を返す
    分解能がない場合は、When::Coordinates::SYSTEM を返す
      # File when/parts.rb, line 1443
1443:     def precision
1444:       @node[0] && @node[0][0].respond_to?(:precision) ? @node[0][0].precision : Coordinates::SYSTEM
1445:     end
to_tm_object(options={}) click to toggle source

ISO19108 の TM オブジェクトに変換する

  options : When::TM::TemporalPosition の生成を行う場合に使用する

  returns : When::TM::Node, When::TM::Edge or When::TM::TopologicalComplex
      # File when/parts.rb, line 1495
1495:     def to_tm_object(options={})
1496:       return nil unless !@reverse && @node.length>0 && @node.length[0]==0
1497:       objects    = []
1498:       primitives = @node.dup
1499:       while (primitives) do
1500:         first, last, primitives = primitives
1501:         if (first[0].eql?(last[0]))
1502:           objects = When::TM::Node.new(When::TM::Instant.new(When.when?(first[0],options)))
1503:         else
1504:           objects = When::TM::Edge.new(When::TM::Node.new(When::TM::Instant.new(When.when?(first[0],options))),
1505:                                        When::TM::Node.new(When::TM::Instant.new(When.when?(last[0],options))))
1506:         end
1507:       end
1508:       return objects[0] if objects.length==1
1509:       return When::TM::TopologicalComplex.new(objects)
1510:     end
|(other) click to toggle source

和集合

  other   : Range or When::Parts::GeometricComplex

  returns : When::Parts::GeometricComplex
    self と other の和集合を返す
      # File when/parts.rb, line 1471
1471:     def |(other)
1472:       other = GeometricComplex.new(other) unless other.kind_of?(GeometricComplex)
1473:       return self if self.reverse && self.node.length==0
1474:       return other | self if !self.reverse && other.reverse
1475:       copy = self.node.dup
1476:       ref  = other.node.dup
1477:       max  = _max(copy.shift.dup, ref.shift.dup) if (other.reverse)
1478:       rev  = max ? false : @reverse
1479:       while (ref.length > 0) do
1480:         first, last, *ref = ref
1481:         updated  = _upper(copy, first, rev)
1482:         updated += _lower(copy, last, rev) if last
1483:         copy = updated
1484:       end
1485:       copy = _lower(copy, max, true) if max
1486:       return GeometricComplex.new(copy, self.reverse)
1487:     end

Private Instance Methods

method_missing(name, *args, &block) click to toggle source

その他のメソッド

  When::Parts::GeometricComplex で定義されていないメソッドは
  処理を first (type: When::TM::(Temporal)Position) に委譲する
      # File when/parts.rb, line 1714
1714:     def method_missing(name, *args, &block)
1715:       first.send(name.to_sym, *args, &block)
1716:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.