Class: Context
- Inherits:
-
Object
- Object
- Context
- Defined in:
- lib/ha/context.rb
Constant Summary collapse
- FILE_SPEC =
"#{Dir.home}/.ha"
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
Instance Method Summary collapse
-
#initialize ⇒ Context
constructor
A new instance of Context.
- #save ⇒ Object
Constructor Details
#initialize ⇒ Context
7 8 9 10 11 12 13 |
# File 'lib/ha/context.rb', line 7 def initialize if File.exist? FILE_SPEC myfile = File.open(FILE_SPEC, "r") @context = YAML.load(myfile.read) end @context ||= {} end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
5 6 7 |
# File 'lib/ha/context.rb', line 5 def context @context end |
Instance Method Details
#save ⇒ Object
15 16 17 18 19 |
# File 'lib/ha/context.rb', line 15 def save puts "saving context" myfile = File.open(FILE_SPEC, "w") myfile.write(@context.to_yaml) end |