Class: Construqt::Flavour::Ciscian::SingleValueVerb

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(section) ⇒ SingleValueVerb

Returns a new instance of SingleValueVerb.



128
129
130
# File 'lib/construqt/flavour/ciscian/ciscian.rb', line 128

def initialize(section)
  self.section=section
end

Instance Attribute Details

#sectionObject

Returns the value of attribute section.



127
128
129
# File 'lib/construqt/flavour/ciscian/ciscian.rb', line 127

def section
  @section
end

#valueObject

Returns the value of attribute value.



127
128
129
# File 'lib/construqt/flavour/ciscian/ciscian.rb', line 127

def value
  @value
end

Class Method Details

.compare(nu, old) ⇒ Object



136
137
138
139
140
141
# File 'lib/construqt/flavour/ciscian/ciscian.rb', line 136

def self.compare(nu, old)
  return [nu] unless old
  return [old.no] unless nu
  return [nu] unless nu.serialize == old.serialize
  [nil]
end

.parse_line(line, lines, section, result) ⇒ Object



153
154
155
156
157
158
159
160
# File 'lib/construqt/flavour/ciscian/ciscian.rb', line 153

def self.parse_line(line, lines, section, result)
  regexp = line.to_s.strip.end_with?("\"") ? /^(.*) (\"[^"]+\")$/ : /^(.*) ([^\s"]+)$/
  if (line.to_s.strip =~ regexp)
    section.add($1, Ciscian::SingleValueVerb).add($2)
  else
    section.add(line.to_s, Ciscian::SingleValueVerb)
  end
end

Instance Method Details

#add(value) ⇒ Object



143
144
145
# File 'lib/construqt/flavour/ciscian/ciscian.rb', line 143

def add(value)
  self.value=value
end

#noObject



147
148
149
150
151
# File 'lib/construqt/flavour/ciscian/ciscian.rb', line 147

def no
  @no="no"
  self.value=nil
  self
end

#serializeObject



132
133
134
# File 'lib/construqt/flavour/ciscian/ciscian.rb', line 132

def serialize
  [[@no, section , value].compact.join(" ")]
end