Class: Rays::Utils::FileUtils::YamlFile
- Inherits:
-
Object
- Object
- Rays::Utils::FileUtils::YamlFile
- Defined in:
- lib/rays/utils/file_utils.rb
Overview
YamlFile allows to work with java .properties files as a ruby hash
Instance Attribute Summary collapse
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Instance Method Summary collapse
-
#initialize(file) ⇒ YamlFile
constructor
A new instance of YamlFile.
- #write ⇒ Object
Constructor Details
#initialize(file) ⇒ YamlFile
Returns a new instance of YamlFile.
82 83 84 85 86 |
# File 'lib/rays/utils/file_utils.rb', line 82 def initialize(file) @file_name = file @properties = {} @properties = YAML::load_file(File.open(@file_name)) || Hash.new end |
Instance Attribute Details
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
80 81 82 |
# File 'lib/rays/utils/file_utils.rb', line 80 def properties @properties end |
Instance Method Details
#write ⇒ Object
88 89 90 91 92 |
# File 'lib/rays/utils/file_utils.rb', line 88 def write File.open(@file_name, 'w') do |out| YAML.dump(@properties, out) end end |