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

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()

  @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:

  • other (BasicObject)

Returns:

  • (T::Boolean)


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

def ==(other)
  case other
  when self.class
    @value == other.value
  else
    false
  end
end

#evaluate(_position) ⇒ ::String

Parameters:

  • _position (Position)

Returns:

  • (::String)


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

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