Class: Apfel::KVPair
- Inherits:
-
Object
- Object
- Apfel::KVPair
- Defined in:
- lib/apfel/kv_pair.rb
Instance Attribute Summary collapse
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#raw_comment ⇒ Object
readonly
Returns the value of attribute raw_comment.
Instance Method Summary collapse
- #comment ⇒ Object
-
#initialize(line, comment) ⇒ KVPair
constructor
A new instance of KVPair.
- #key ⇒ Object
- #value ⇒ Object
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
#line ⇒ Object (readonly)
Returns the value of attribute line.
3 4 5 |
# File 'lib/apfel/kv_pair.rb', line 3 def line @line end |
#raw_comment ⇒ Object (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
#comment ⇒ Object
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 |
#key ⇒ Object
10 11 12 |
# File 'lib/apfel/kv_pair.rb', line 10 def key line.key.strip unless line.key.nil? end |
#value ⇒ Object
14 15 16 |
# File 'lib/apfel/kv_pair.rb', line 14 def value line.value.strip unless line.key.nil? end |