Class: Lino::Model::EnvironmentVariable

Inherits:
Object
  • Object
show all
Defined in:
lib/lino/model/environment_variable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value, opts = {}) ⇒ EnvironmentVariable

Returns a new instance of EnvironmentVariable.



12
13
14
15
16
17
# File 'lib/lino/model/environment_variable.rb', line 12

def initialize(name, value, opts = {})
  opts = with_defaults(opts)
  @name = name
  @value = value
  @quoting = opts[:quoting]
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/lino/model/environment_variable.rb', line 8

def name
  @name
end

#quotingObject (readonly)

Returns the value of attribute quoting.



8
9
10
# File 'lib/lino/model/environment_variable.rb', line 8

def quoting
  @quoting
end

#valueObject (readonly)

Returns the value of attribute value.



8
9
10
# File 'lib/lino/model/environment_variable.rb', line 8

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



33
34
35
36
# File 'lib/lino/model/environment_variable.rb', line 33

def ==(other)
  self.class == other.class &&
    state == other.state
end

#arrayObject Also known as: to_a



28
29
30
# File 'lib/lino/model/environment_variable.rb', line 28

def array
  [name.to_s, value.to_s]
end

#hashObject



40
41
42
# File 'lib/lino/model/environment_variable.rb', line 40

def hash
  [self.class, state].hash
end

#quoted_valueObject



19
20
21
# File 'lib/lino/model/environment_variable.rb', line 19

def quoted_value
  "#{quoting}#{value.to_s.gsub(quoting.to_s, "\\#{quoting}")}#{quoting}"
end

#stringObject Also known as: to_s



23
24
25
# File 'lib/lino/model/environment_variable.rb', line 23

def string
  "#{name}=#{quoted_value}"
end