Module: Hoot::Metadata
- Defined in:
- lib/hoot/metadata.rb
Class Method Summary collapse
Class Method Details
.get ⇒ Object
31 32 33 |
# File 'lib/hoot/metadata.rb', line 31 def self.get return YAML::load_file(@path) if File.exist?(@path) end |
.save ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/hoot/metadata.rb', line 35 def self.save if File.write(@path, @m.to_yaml) true else false end end |
.set(key, value) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/hoot/metadata.rb', line 9 def self.set(key, value) return if value.nil? return unless keys.include?(key) create unless File.exist?(@path) if File.exist?(@path) @m = YAML::load_file(@path) end if @m.nil? || @m == false @m = {} end if valid?(key, value) # key = key.to_s Still not sure if I want to remove the ':' from the .yml file. @m[key] = value save else abort('You are trying to set invalid options.') end end |