Class: Apstrings::KVPair

Inherits:
Object
  • Object
show all
Defined in:
lib/apstrings/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/apstrings/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/apstrings/kv_pair.rb', line 3

def line
  @line
end

#raw_commentObject (readonly)

Returns the value of attribute raw_comment.



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

def raw_comment
  @raw_comment
end

Instance Method Details

#commentObject



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

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/apstrings/kv_pair.rb', line 10

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

#valueObject



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

def value
 # puts line
 line.value unless line.key.nil? 
end