Class: CSVPlusPlus::Entities::Entity

Inherits:
Object
  • Object
show all
Extended by:
T::Helpers, T::Sig
Defined in:
lib/csv_plus_plus/entities/entity.rb

Overview

A basic building block of the abstract syntax tree (AST)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, id: nil) ⇒ Entity

Returns a new instance of Entity.

Parameters:



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

def initialize(type, id: nil)
  @type = type
  @id = ::T.let(id&.downcase&.to_sym || nil, ::T.nilable(::Symbol))
end

Instance Attribute Details

#idSymbol (readonly)

The identifier of the entity. For functions this is the function name, for variables it's the variable name

Returns:

  • (Symbol)

    the current value of id



12
13
14
# File 'lib/csv_plus_plus/entities/entity.rb', line 12

def id
  @id
end

#typeEntities::Type (readonly)

The type of the entity. Each type should have a corresponding class definition in CSVPlusPlus::Entities

Returns:



12
13
14
# File 'lib/csv_plus_plus/entities/entity.rb', line 12

def type
  @type
end

Instance Method Details

#==(other) ⇒ boolean

Each class should define it's own version of #==

Parameters:

Returns:

  • (boolean)


37
38
39
# File 'lib/csv_plus_plus/entities/entity.rb', line 37

def ==(other)
  self.class == other.class && @type == other.type && @id == other.id
end

#evaluate(_runtime) ⇒ ::String

Uses the given runtime to evaluate itself in the current context

Parameters:

  • _runtime (Runtime)

    The current runtime

Returns:

  • (::String)


47
# File 'lib/csv_plus_plus/entities/entity.rb', line 47

def evaluate(_runtime); end