Class: Apfel::KVPair

Inherits:
Object
  • Object
show all
Defined in:
lib/apfel/kv_pair.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line, comment) ⇒ KVPair

Returns a new instance of KVPair.



5
6
7
8
# File 'lib/apfel/kv_pair.rb', line 5

def initialize(line, comment)
 @line = line
 @raw_comment = comment
end

Instance Attribute Details

#lineObject (readonly)

Returns the value of attribute line.



3
4
5
# File 'lib/apfel/kv_pair.rb', line 3

def line
  @line
end

#raw_commentObject (readonly)

Returns the value of attribute raw_comment.



3
4
5
# File 'lib/apfel/kv_pair.rb', line 3

def raw_comment
  @raw_comment
end

Instance Method Details

#commentObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/apfel/kv_pair.rb', line 18

def comment
  if raw_comment.nil?
    @raw_comment = ""
  else
    raw_comment.gsub!(/(\/\*)|(\*\/)/,"")
    raw_comment.gsub!("\n", " ")
    raw_comment.gsub!(/\s+/, " ")
    raw_comment.strip
  end
end

#keyObject



10
11
12
# File 'lib/apfel/kv_pair.rb', line 10

def key
 line.key.strip unless line.key.nil?
end

#valueObject



14
15
16
# File 'lib/apfel/kv_pair.rb', line 14

def value
 line.value.strip unless line.key.nil?
end