Class: Cliptic::Config::Reader
- Inherits:
-
Object
- Object
- Cliptic::Config::Reader
- Defined in:
- lib/cliptic/config.rb
Instance Attribute Summary collapse
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
Instance Method Summary collapse
-
#initialize ⇒ Reader
constructor
A new instance of Reader.
- #read(key:) ⇒ Object
Constructor Details
Instance Attribute Details
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
59 60 61 |
# File 'lib/cliptic/config.rb', line 59 def lines @lines end |
Instance Method Details
#read(key:) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/cliptic/config.rb', line 63 def read(key:) lines.grep(/^\s*#{key}/) .map{|l| l.gsub(/^\s*#{key}\s+/, "") .split(/\s+/)} .map{|k, v| [k.to_sym, v.to_i]} .to_h end |