Class: Stenographer::Message

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, name, body) ⇒ Message

Returns a new instance of Message.



6
7
8
9
10
11
# File 'lib/stenographer/message.rb', line 6

def initialize(id, name, body)
  @id   = id
  @name = name
  @body = body
  @words = Word.split_message(self)
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



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

def body
  @body
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#wordsObject

Returns the value of attribute words.



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

def words
  @words
end

Instance Method Details

#explodeObject



19
20
21
# File 'lib/stenographer/message.rb', line 19

def explode
  Word.split_message(self)
end

#include?(query = nil) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
# File 'lib/stenographer/message.rb', line 13

def include?(query=nil)
  return true if query.nil?

  body.include?(query)
end


23
24
25
26
# File 'lib/stenographer/message.rb', line 23

def print(opts={})
  code = opts[:highlighted] ? ">> %-17s %0s" : "%-20s %0s"
  puts printf(code, name, body)
end

#to_sObject



28
29
30
# File 'lib/stenographer/message.rb', line 28

def to_s
  "Message <name: #{name}, body: #{body}>"
end