Class: Twterm::Image::Attr

Inherits:
Twterm::Image show all
Defined in:
lib/twterm/image/attr.rb

Direct Known Subclasses

Bold, Color, Dim, Underlined

Instance Method Summary collapse

Methods inherited from Twterm::Image

#!, #-, #_, #at, blank_line, #bold, #brackets, checkbox, #color, #column, cursor, #dim, empty, #line, number, #parens, plural, remaining_resource, string, toggle_switch, #underlined, whitespace, #|

Constructor Details

#initialize(image) ⇒ Attr

Returns a new instance of Attr.

Parameters:



5
6
7
8
9
# File 'lib/twterm/image/attr.rb', line 5

def initialize(image)
  super()

  @image = image
end

Instance Method Details

#heightObject



11
12
13
# File 'lib/twterm/image/attr.rb', line 11

def height
  image.height
end

#render(window) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/twterm/image/attr.rb', line 15

def render(window)
  image, attr =
    if image.is_a?(self.class) # fuse attributes when possible
      [image.image, self.attr | image.attr]
    else
      [self.image, self.attr]
    end

  window.attron(attr)
  image.at(line, column).render(window)
  window.attroff(attr)
end

#widthObject



28
29
30
# File 'lib/twterm/image/attr.rb', line 28

def width
  image.width
end