Class: Exfuz::Cell
- Inherits:
-
Object
show all
- Includes:
- Util
- Defined in:
- lib/exfuz/cell.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Util
#match?, wsl?, wsl_to_windows
Constructor Details
#initialize(value:, row: nil, col: nil, address: nil) ⇒ Cell
Returns a new instance of Cell.
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/exfuz/cell.rb', line 13
def initialize(value:, row: nil, col: nil, address: nil)
if row && col
@row = row
@col = col
elsif address
@row, @col = to_idx(address)
else
raise "argument error. row: #{row}, col: #{col}, address: #{address}"
end
@value = value
@text = @value.to_s
end
|
Instance Attribute Details
#col ⇒ Object
Returns the value of attribute col.
9
10
11
|
# File 'lib/exfuz/cell.rb', line 9
def col
@col
end
|
#row ⇒ Object
Returns the value of attribute row.
9
10
11
|
# File 'lib/exfuz/cell.rb', line 9
def row
@row
end
|
#value ⇒ Object
Returns the value of attribute value.
9
10
11
|
# File 'lib/exfuz/cell.rb', line 9
def value
@value
end
|
Class Method Details
.name ⇒ Object
5
6
7
|
# File 'lib/exfuz/cell.rb', line 5
def self.name
:textable
end
|
Instance Method Details
#==(other) ⇒ Object
37
38
39
40
41
|
# File 'lib/exfuz/cell.rb', line 37
def ==(other)
return false if other.nil? || !other.instance_of?(Exfuz::Cell)
[@row, @col, @value] == [other.row, other.col, other.value]
end
|
#hash ⇒ Object
43
44
45
|
# File 'lib/exfuz/cell.rb', line 43
def hash
[@row, @col, @value].hash
end
|
#jump_info ⇒ Object
47
48
49
|
# File 'lib/exfuz/cell.rb', line 47
def jump_info
{ Exfuz::Cell.name => { row: @row, col: @col } }
end
|
#position_s(format: :address) ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'lib/exfuz/cell.rb', line 28
def position_s(format: :address)
case format
when :address
to_address(@col, row)
when :index
"$#{col}$#{row}"
end
end
|