Class: HorseSay
- Inherits:
-
Object
- Object
- HorseSay
- Defined in:
- lib/horse_say.rb,
lib/horse_say/version.rb
Constant Summary collapse
- UPPER_LINE_CHAR =
'-'
- BOTTOM_LINE_CHAR =
'='
- TALK_LINE_CHAR =
'/'
- VERSION =
'0.1.1'
Class Method Summary collapse
Class Method Details
.interpolate_text(text) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/horse_say.rb', line 16 def interpolate_text(text) " #{UPPER_LINE_CHAR * text.length} < #{text} > #{BOTTOM_LINE_CHAR * text.length} #{TALK_LINE_CHAR} #{TALK_LINE_CHAR} #{TALK_LINE_CHAR} #{self} " end |
.say(text) ⇒ Object
11 12 13 14 |
# File 'lib/horse_say.rb', line 11 def say(text) text = interpolate_text(text.gsub(/[\n\t]/, '')) puts(text) end |
.to_s ⇒ Object
28 29 30 |
# File 'lib/horse_say.rb', line 28 def to_s @to_s ||= File.read("#{__dir__}/horse.txt") end |