Class: AsciinemaWin::ScreenBuffer::Cell
- Inherits:
-
Data
- Object
- Data
- AsciinemaWin::ScreenBuffer::Cell
- Defined in:
- lib/asciinema_win/screen_buffer.rb
Overview
Cell data structure representing a single character cell
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#background ⇒ Object
readonly
Returns the value of attribute background.
-
#char ⇒ Object
readonly
Returns the value of attribute char.
-
#foreground ⇒ Object
readonly
Returns the value of attribute foreground.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
True if this cell equals another.
-
#empty? ⇒ Boolean
True if cell is empty (space with default colors).
-
#hash ⇒ Integer
Hash code for this cell.
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/asciinema_win/screen_buffer.rb', line 30 Cell = Data.define(:char, :foreground, :background, :attributes) do # @return [Boolean] True if cell is empty (space with default colors) def empty? (char == " " || char == "\0") && foreground == 7 && background == 0 end # @return [Boolean] True if this cell equals another def ==(other) return false unless other.is_a?(Cell) char == other.char && foreground == other.foreground && background == other.background end alias eql? == # @return [Integer] Hash code for this cell def hash [char, foreground, background].hash end end |
#background ⇒ Object (readonly)
Returns the value of attribute background
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/asciinema_win/screen_buffer.rb', line 30 Cell = Data.define(:char, :foreground, :background, :attributes) do # @return [Boolean] True if cell is empty (space with default colors) def empty? (char == " " || char == "\0") && foreground == 7 && background == 0 end # @return [Boolean] True if this cell equals another def ==(other) return false unless other.is_a?(Cell) char == other.char && foreground == other.foreground && background == other.background end alias eql? == # @return [Integer] Hash code for this cell def hash [char, foreground, background].hash end end |
#char ⇒ Object (readonly)
Returns the value of attribute char
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/asciinema_win/screen_buffer.rb', line 30 Cell = Data.define(:char, :foreground, :background, :attributes) do # @return [Boolean] True if cell is empty (space with default colors) def empty? (char == " " || char == "\0") && foreground == 7 && background == 0 end # @return [Boolean] True if this cell equals another def ==(other) return false unless other.is_a?(Cell) char == other.char && foreground == other.foreground && background == other.background end alias eql? == # @return [Integer] Hash code for this cell def hash [char, foreground, background].hash end end |
#foreground ⇒ Object (readonly)
Returns the value of attribute foreground
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/asciinema_win/screen_buffer.rb', line 30 Cell = Data.define(:char, :foreground, :background, :attributes) do # @return [Boolean] True if cell is empty (space with default colors) def empty? (char == " " || char == "\0") && foreground == 7 && background == 0 end # @return [Boolean] True if this cell equals another def ==(other) return false unless other.is_a?(Cell) char == other.char && foreground == other.foreground && background == other.background end alias eql? == # @return [Integer] Hash code for this cell def hash [char, foreground, background].hash end end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Returns True if this cell equals another.
37 38 39 40 41 42 43 |
# File 'lib/asciinema_win/screen_buffer.rb', line 37 def ==(other) return false unless other.is_a?(Cell) char == other.char && foreground == other.foreground && background == other.background end |
#empty? ⇒ Boolean
Returns True if cell is empty (space with default colors).
32 33 34 |
# File 'lib/asciinema_win/screen_buffer.rb', line 32 def empty? (char == " " || char == "\0") && foreground == 7 && background == 0 end |
#hash ⇒ Integer
Returns Hash code for this cell.
48 49 50 |
# File 'lib/asciinema_win/screen_buffer.rb', line 48 def hash [char, foreground, background].hash end |