Class: Rconftool::Setting
Overview
Object to represent a single setting
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #<<(str) ⇒ Object
-
#add_comment(str) ⇒ Object
Add text to ‘comment’ portion of setting, prefixing each line with ‘#’.
-
#initialize(name, version) ⇒ Setting
constructor
A new instance of Setting.
- #to_s ⇒ Object
Constructor Details
#initialize(name, version) ⇒ Setting
Returns a new instance of Setting.
165 166 167 168 169 170 171 |
# File 'lib/rconftool.rb', line 165 def initialize(name, version) @name = name.gsub(/\s+/,'') @version = version.gsub(/s+/,'') @comment = "" @content = "" @in_content = false end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
163 164 165 |
# File 'lib/rconftool.rb', line 163 def content @content end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
162 163 164 |
# File 'lib/rconftool.rb', line 162 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
162 163 164 |
# File 'lib/rconftool.rb', line 162 def version @version end |
Instance Method Details
#<<(str) ⇒ Object
172 173 174 175 176 177 178 179 |
# File 'lib/rconftool.rb', line 172 def <<(str) @in_content = true unless /\A#/ =~ str if @in_content @content << str else @comment << str end end |
#add_comment(str) ⇒ Object
Add text to ‘comment’ portion of setting, prefixing each line with ‘#’
181 182 183 |
# File 'lib/rconftool.rb', line 181 def add_comment(str) @comment << str.gsub(/^/,'#') end |