Class: Twterm::Image::StringImage

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

Instance Method Summary collapse

Methods inherited from Twterm::Image

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

Constructor Details

#initialize(string) ⇒ StringImage

Returns a new instance of StringImage.



4
5
6
# File 'lib/twterm/image/string_image.rb', line 4

def initialize(string)
  @string = string
end

Instance Method Details

#-(other) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/twterm/image/string_image.rb', line 8

def -(other)
  if other.is_a?(self.class)
    self.class.new(string + other.string)
  else
    super
  end
end

#heightObject



16
17
18
# File 'lib/twterm/image/string_image.rb', line 16

def height
  1
end

#render(window) ⇒ Object



20
21
22
23
# File 'lib/twterm/image/string_image.rb', line 20

def render(window)
  window.setpos(line, column)
  window.addstr(string)
end

#to_sObject



25
26
27
# File 'lib/twterm/image/string_image.rb', line 25

def to_s
  @string.dup
end

#widthObject



29
30
31
# File 'lib/twterm/image/string_image.rb', line 29

def width
  string.width
end