Class: Spread2RDF::Coord
- Inherits:
-
Struct
- Object
- Struct
- Spread2RDF::Coord
- Defined in:
- lib/spread2rdf/coord.rb
Instance Attribute Summary collapse
-
#column ⇒ Object
Returns the value of attribute column.
-
#row ⇒ Object
Returns the value of attribute row.
Class Method Summary collapse
Instance Method Summary collapse
- #column_as_index ⇒ Object
- #column_as_number ⇒ Object
- #increment_column(count = 1) ⇒ Object
-
#initialize(*args) ⇒ Coord
constructor
A new instance of Coord.
- #to_s ⇒ Object
- #to_sym ⇒ Object
Constructor Details
#initialize(*args) ⇒ Coord
Returns a new instance of Coord.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/spread2rdf/coord.rb', line 3 def initialize(*args) case args.length when 2 then super when 1 case args = args.first when Hash super(args[:column], args[:row]) when Symbol, String coord = args.to_s raise "Invalid cell coordinates #{coord}" unless coord =~ /([A-Za-z]+)(\d+)/ super(Regexp.last_match[1], Regexp.last_match[2].to_i) else raise ArgumentError, "can't handle argument #{args}" end else raise ArgumentError, "too many arguments: #{args}" end end |
Instance Attribute Details
#column ⇒ Object
Returns the value of attribute column
2 3 4 |
# File 'lib/spread2rdf/coord.rb', line 2 def column @column end |
#row ⇒ Object
Returns the value of attribute row
2 3 4 |
# File 'lib/spread2rdf/coord.rb', line 2 def row @row end |
Class Method Details
.increment_column(column, count = 1) ⇒ Object
43 44 45 |
# File 'lib/spread2rdf/coord.rb', line 43 def increment_column(column, count=1) Roo::Base.number_to_letter(Roo::Base.letter_to_number(column) + count) end |
Instance Method Details
#column_as_index ⇒ Object
24 25 26 |
# File 'lib/spread2rdf/coord.rb', line 24 def column_as_index column_as_number - 1 end |
#column_as_number ⇒ Object
20 21 22 |
# File 'lib/spread2rdf/coord.rb', line 20 def column_as_number Roo::Base.letter_to_number(column) end |
#increment_column(count = 1) ⇒ Object
28 29 30 |
# File 'lib/spread2rdf/coord.rb', line 28 def increment_column(count = 1) self.class.increment_column(self.column, count) end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/spread2rdf/coord.rb', line 32 def to_s "#{column}#{row}" end |
#to_sym ⇒ Object
36 37 38 |
# File 'lib/spread2rdf/coord.rb', line 36 def to_sym to_s.to_sym end |