Class: CSVPlusPlus::Entities::String

Inherits:
Entity
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/csv_plus_plus/entities/string.rb

Overview

A string value

Instance Attribute Summary collapse

Attributes inherited from Entity

#id, #type

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ String

Returns a new instance of String.

Parameters:

  • value (String)

    The string that has been parsed out of the template



17
18
19
20
21
# File 'lib/csv_plus_plus/entities/string.rb', line 17

def initialize(value)
  super(::CSVPlusPlus::Entities::Type::String)

  @value = ::T.let(value.gsub(/^"|"$/, ''), ::String)
end

Instance Attribute Details

#valueString (readonly)

Returns the current value of value.

Returns:

  • (String)

    the current value of value



9
10
11
# File 'lib/csv_plus_plus/entities/string.rb', line 9

def value
  @value
end

Instance Method Details

#==(other) ⇒ T::Boolean

Parameters:

Returns:

  • (T::Boolean)


35
36
37
38
39
# File 'lib/csv_plus_plus/entities/string.rb', line 35

def ==(other)
  return false unless super

  other.is_a?(self.class) && @value == other.value
end

#evaluate(_runtime) ⇒ ::String

Parameters:

Returns:

  • (::String)


27
28
29
# File 'lib/csv_plus_plus/entities/string.rb', line 27

def evaluate(_runtime)
  "\"#{@value}\""
end