Class: Falling::Messaging::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/falling/messaging/message.rb

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Message



4
5
6
# File 'lib/falling/messaging/message.rb', line 4

def initialize(text)
  @text = text
end

Instance Method Details

#format(for_width:) ⇒ Object

FIXME: One day we will properly break words.



14
15
16
# File 'lib/falling/messaging/message.rb', line 14

def format(for_width:)
  text.scan(/.{1,#{for_width}}/)
end

#height(at_width:) ⇒ Object



8
9
10
11
# File 'lib/falling/messaging/message.rb', line 8

def height(at_width:)
  raise "not enough screen space" if at_width < 24
  format(for_width: at_width).length
end