Class: YamlMaster::Context
- Inherits:
-
Object
- Object
- YamlMaster::Context
- Defined in:
- lib/yaml_master.rb
Instance Attribute Summary collapse
-
#master_path ⇒ Object
readonly
Returns the value of attribute master_path.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Instance Method Summary collapse
-
#initialize(master_path, properties) ⇒ Context
constructor
A new instance of Context.
- #read_file_if_exist(path) ⇒ Object
- #render_master ⇒ Object
- #user_home ⇒ Object
Constructor Details
#initialize(master_path, properties) ⇒ Context
Returns a new instance of Context.
110 111 112 113 |
# File 'lib/yaml_master.rb', line 110 def initialize(master_path, properties) @master_path = master_path @properties = properties end |
Instance Attribute Details
#master_path ⇒ Object (readonly)
Returns the value of attribute master_path.
108 109 110 |
# File 'lib/yaml_master.rb', line 108 def master_path @master_path end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
108 109 110 |
# File 'lib/yaml_master.rb', line 108 def properties @properties end |
Instance Method Details
#read_file_if_exist(path) ⇒ Object
119 120 121 122 |
# File 'lib/yaml_master.rb', line 119 def read_file_if_exist(path) return nil unless File.exist?(path) File.read(path) end |
#render_master ⇒ Object
124 125 126 |
# File 'lib/yaml_master.rb', line 124 def render_master ERB.new(File.read(@master_path)).result(binding) end |
#user_home ⇒ Object
115 116 117 |
# File 'lib/yaml_master.rb', line 115 def user_home Pathname(ENV["HOME"]) end |