Class: Context

Inherits:
Object
  • Object
show all
Defined in:
lib/ha/context.rb

Constant Summary collapse

FILE_SPEC =
"#{Dir.home}/.ha"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContext



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

#contextObject

Returns the value of attribute context.



5
6
7
# File 'lib/ha/context.rb', line 5

def context
  @context
end

Instance Method Details

#saveObject



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