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.
169 170 171 172 173 174 175 |
# File 'lib/rconftool.rb', line 169 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.
167 168 169 |
# File 'lib/rconftool.rb', line 167 def content @content end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
166 167 168 |
# File 'lib/rconftool.rb', line 166 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
166 167 168 |
# File 'lib/rconftool.rb', line 166 def version @version end |
Instance Method Details
#<<(str) ⇒ Object
176 177 178 179 180 181 182 183 |
# File 'lib/rconftool.rb', line 176 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 ‘#’
185 186 187 |
# File 'lib/rconftool.rb', line 185 def add_comment(str) @comment << str.gsub(/^/,'#') end |