Class: ElmInstall::Base
- Inherits:
-
Object
- Object
- ElmInstall::Base
- Extended by:
- Forwardable
- Defined in:
- lib/elm_install/base.rb
Overview
This class is the base for the Cache and GitResolver packages.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
Instance Method Summary collapse
-
#directory ⇒ Object
Returns the directory where the cache is stored.
- #file ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
-
#load ⇒ Object
Loads a cache from the json file.
-
#save ⇒ Object
Saves the cache into the json file.
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
10 11 12 13 14 |
# File 'lib/elm_install/base.rb', line 10 def initialize( = {}) @options = @cache = {} load end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
6 7 8 |
# File 'lib/elm_install/base.rb', line 6 def cache @cache end |
Instance Method Details
#directory ⇒ Object
Returns the directory where the cache is stored.
33 34 35 |
# File 'lib/elm_install/base.rb', line 33 def directory @options[:directory] end |
#file ⇒ Object
28 29 30 |
# File 'lib/elm_install/base.rb', line 28 def file File.join(directory, @file) end |
#load ⇒ Object
Loads a cache from the json file.
22 23 24 25 26 |
# File 'lib/elm_install/base.rb', line 22 def load @cache = JSON.parse(File.read(file)) rescue @cache = {} end |
#save ⇒ Object
Saves the cache into the json file.
17 18 19 |
# File 'lib/elm_install/base.rb', line 17 def save File.binwrite(file, JSON.pretty_generate(@cache)) end |