Class: Cell

Inherits:
Object
  • Object
show all
Defined in:
lib/asciinema/cell.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, brush) ⇒ Cell

Returns a new instance of Cell.



9
10
11
12
# File 'lib/asciinema/cell.rb', line 9

def initialize(text, brush)
  @text = text
  @brush = brush
end

Instance Attribute Details

#brushObject (readonly)

Returns the value of attribute brush.



5
6
7
# File 'lib/asciinema/cell.rb', line 5

def brush
  @brush
end

#textObject (readonly)

Returns the value of attribute text.



5
6
7
# File 'lib/asciinema/cell.rb', line 5

def text
  @text
end

Instance Method Details

#==(other) ⇒ Object



18
19
20
# File 'lib/asciinema/cell.rb', line 18

def ==(other)
  text == other.text && brush == other.brush
end

#[](*args) ⇒ Object



22
23
24
# File 'lib/asciinema/cell.rb', line 22

def [](*args)
  self.class.new(text[*args], brush)
end

#as_jsonObject



26
27
28
# File 'lib/asciinema/cell.rb', line 26

def as_json(*)
  [text, brush.as_json]
end

#empty?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/asciinema/cell.rb', line 14

def empty?
  text.blank? && brush.default?
end

#to_fObject



30
31
32
# File 'lib/asciinema/cell.rb', line 30

def to_f
  size
end