Class: Envo::StringVal
- Inherits:
-
Object
- Object
- Envo::StringVal
- Defined in:
- lib/envo/val/string_val.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #accept_assign?(other) ⇒ Boolean
- #clean! ⇒ Object
-
#initialize(str) ⇒ StringVal
constructor
A new instance of StringVal.
- #invalid_description ⇒ Object
- #list? ⇒ Boolean
- #pretty_print(ctx) ⇒ Object
- #to_env_s ⇒ Object
- #to_list ⇒ Object
- #to_s ⇒ Object
-
#type ⇒ Object
casts.
Constructor Details
#initialize(str) ⇒ StringVal
Returns a new instance of StringVal.
3 4 5 |
# File 'lib/envo/val/string_val.rb', line 3 def initialize(str) @value = str end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/envo/val/string_val.rb', line 6 def value @value end |
Instance Method Details
#accept_assign?(other) ⇒ Boolean
12 13 14 |
# File 'lib/envo/val/string_val.rb', line 12 def accept_assign?(other) true end |
#clean! ⇒ Object
36 37 38 |
# File 'lib/envo/val/string_val.rb', line 36 def clean! @value = nil if @value && @value.empty? end |
#invalid_description ⇒ Object
15 16 17 |
# File 'lib/envo/val/string_val.rb', line 15 def invalid_description @value.empty? ? "empty string" : nil end |
#list? ⇒ Boolean
18 19 20 |
# File 'lib/envo/val/string_val.rb', line 18 def list? false end |
#pretty_print(ctx) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/envo/val/string_val.rb', line 27 def pretty_print(ctx) ctx.puts @value inv = invalid_description return if !inv ctx.warn "Warning: #{inv}" end |
#to_env_s ⇒ Object
33 34 35 |
# File 'lib/envo/val/string_val.rb', line 33 def to_env_s @value end |
#to_list ⇒ Object
21 22 23 |
# File 'lib/envo/val/string_val.rb', line 21 def to_list return ListVal.new([@value]) end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/envo/val/string_val.rb', line 24 def to_s @value end |
#type ⇒ Object
casts
9 10 11 |
# File 'lib/envo/val/string_val.rb', line 9 def type :string end |