Class: CSVPlusPlus::Entities::CellReference
- Defined in:
- lib/csv_plus_plus/entities/cell_reference.rb
Overview
A reference to a cell
Constant Summary collapse
- A1_NOTATION_REGEXP =
/(['\w]+!)?\w+:\w+/
Instance Attribute Summary collapse
-
#cell_reference ⇒ String
readonly
The cell reference in A1 format.
Attributes inherited from Entity
Class Method Summary collapse
-
.from_index(cell_index:, row_index:) ⇒ CellReference
Create a
CellReferenceto the given indexes. -
.valid_cell_reference?(cell_reference_string) ⇒ boolean
Does the given
cell_reference_stringconform to a valid cell reference?.
Instance Method Summary collapse
- #==(other) ⇒ Boolean
-
#initialize(cell_reference) ⇒ CellReference
constructor
A new instance of CellReference.
- #to_s ⇒ ::String
Methods inherited from Entity
#method_missing, #respond_to_missing?
Constructor Details
#initialize(cell_reference) ⇒ CellReference
Returns a new instance of CellReference.
43 44 45 46 47 |
# File 'lib/csv_plus_plus/entities/cell_reference.rb', line 43 def initialize(cell_reference) super(:cell_reference) @cell_reference = cell_reference end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class CSVPlusPlus::Entities::Entity
Instance Attribute Details
#cell_reference ⇒ String (readonly)
The cell reference in A1 format
11 12 13 |
# File 'lib/csv_plus_plus/entities/cell_reference.rb', line 11 def cell_reference @cell_reference end |
Class Method Details
.from_index(cell_index:, row_index:) ⇒ CellReference
Create a CellReference to the given indexes
23 24 25 26 27 28 |
# File 'lib/csv_plus_plus/entities/cell_reference.rb', line 23 def self.from_index(cell_index:, row_index:) return unless row_index || cell_index # I can't just extend this class due to circular references :( ::Class.new.extend(::CSVPlusPlus::Entities::ASTBuilder).ref(cell_index:, row_index:) end |
.valid_cell_reference?(cell_reference_string) ⇒ boolean
Does the given cell_reference_string conform to a valid cell reference?
38 39 40 |
# File 'lib/csv_plus_plus/entities/cell_reference.rb', line 38 def self.valid_cell_reference?(cell_reference_string) !(cell_reference_string =~ ::CSVPlusPlus::Entities::CellReference::A1_NOTATION_REGEXP).nil? end |
Instance Method Details
#==(other) ⇒ Boolean
55 56 57 |
# File 'lib/csv_plus_plus/entities/cell_reference.rb', line 55 def ==(other) super && @cell_reference == other.cell_reference end |
#to_s ⇒ ::String
50 51 52 |
# File 'lib/csv_plus_plus/entities/cell_reference.rb', line 50 def to_s @cell_reference end |