Class: Construqt::Flavour::Ciscian::Result::Lines::Line

Inherits:
Object
  • Object
show all
Defined in:
lib/construqt/flavour/ciscian/ciscian.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str, nr) ⇒ Line

Returns a new instance of Line.



33
34
35
36
# File 'lib/construqt/flavour/ciscian/ciscian.rb', line 33

def initialize(str, nr)
  @to_s = str
  @nr = nr
end

Instance Attribute Details

#nrObject (readonly)

Returns the value of attribute nr.



32
33
34
# File 'lib/construqt/flavour/ciscian/ciscian.rb', line 32

def nr
  @nr
end

#to_sObject (readonly)

Returns the value of attribute to_s.



32
33
34
# File 'lib/construqt/flavour/ciscian/ciscian.rb', line 32

def to_s
  @to_s
end

Instance Method Details

#<=>(other) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/construqt/flavour/ciscian/ciscian.rb', line 37

def <=>(other)
  a = self.to_s
  b = other.to_s
  match_a=/^(.*[^\d])(\d+)$/.match(a)||[nil,a,1]
  match_b=/^(.*[^\d])(\d+)$/.match(b)||[nil,b,1]
  #puts match_a, match_b, a, b
  ret = match_a[1]<=>match_b[1]
  ret = match_a[2].to_i<=>match_b[2].to_i  if ret==0
  ret
end