Class: AsciinemaWin::ScreenBuffer::Cell

Inherits:
Data
  • Object
show all
Defined in:
lib/asciinema_win/screen_buffer.rb

Overview

Cell data structure representing a single character cell

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes

Returns:

  • (Object)

    the current value of 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

#backgroundObject (readonly)

Returns the value of attribute background

Returns:

  • (Object)

    the current value of 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

#charObject (readonly)

Returns the value of attribute char

Returns:

  • (Object)

    the current value of 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

#foregroundObject (readonly)

Returns the value of attribute foreground

Returns:

  • (Object)

    the current value of 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.

Returns:

  • (Boolean)

    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).

Returns:

  • (Boolean)

    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

#hashInteger

Returns Hash code for this cell.

Returns:

  • (Integer)

    Hash code for this cell



48
49
50
# File 'lib/asciinema_win/screen_buffer.rb', line 48

def hash
  [char, foreground, background].hash
end