Class: CSVPlusPlus::Entities::Entity
- Inherits:
-
Object
- Object
- CSVPlusPlus::Entities::Entity
- 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)
Direct Known Subclasses
Boolean, CellReference, Date, EntityWithArguments, Number, RuntimeValue, String, Variable
Instance Attribute Summary collapse
-
#id ⇒ Symbol
readonly
The identifier of the entity.
-
#type ⇒ Entities::Type
readonly
The type of the entity.
Instance Method Summary collapse
-
#==(other) ⇒ boolean
Each class should define it's own version of #==.
-
#evaluate(_runtime) ⇒ ::String
Uses the given
runtimeto evaluate itself in the current context. -
#initialize(type, id: nil) ⇒ Entity
constructor
A new instance of Entity.
Constructor Details
#initialize(type, id: nil) ⇒ Entity
Returns a new instance of Entity.
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
#id ⇒ Symbol (readonly)
The identifier of the entity. For functions this is the function name, for variables it's the variable name
12 13 14 |
# File 'lib/csv_plus_plus/entities/entity.rb', line 12 def id @id end |
#type ⇒ Entities::Type (readonly)
The type of the entity. Each type should have a corresponding class definition in CSVPlusPlus::Entities
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 #==
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
47 |
# File 'lib/csv_plus_plus/entities/entity.rb', line 47 def evaluate(_runtime); end |