Class: PopulateEnv::Formatters::EnvShellSection
- Inherits:
-
Object
- Object
- PopulateEnv::Formatters::EnvShellSection
- Defined in:
- lib/populate_env/formatters/env_shell_section.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#export ⇒ Object
readonly
Returns the value of attribute export.
Instance Method Summary collapse
-
#initialize(attribute, export: false) ⇒ EnvShellSection
constructor
A new instance of EnvShellSection.
- #prefix ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(attribute, export: false) ⇒ EnvShellSection
Returns a new instance of EnvShellSection.
6 7 8 9 |
# File 'lib/populate_env/formatters/env_shell_section.rb', line 6 def initialize(attribute, export: false) @attribute = attribute @export = export end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
4 5 6 |
# File 'lib/populate_env/formatters/env_shell_section.rb', line 4 def attribute @attribute end |
#export ⇒ Object (readonly)
Returns the value of attribute export.
4 5 6 |
# File 'lib/populate_env/formatters/env_shell_section.rb', line 4 def export @export end |
Instance Method Details
#prefix ⇒ Object
11 12 13 |
# File 'lib/populate_env/formatters/env_shell_section.rb', line 11 def prefix export ? "export " : "" end |
#to_s ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/populate_env/formatters/env_shell_section.rb', line 15 def to_s output = '' if attribute.description attribute.description.each_line do |line| output << "# #{line}\n" end end if attribute.optional? && attribute.value.nil? output << "# " end output << "#{prefix}#{attribute.name}=#{attribute.value}\n" end |