Class: Komonjo::Model::Message
- Inherits:
-
Object
- Object
- Komonjo::Model::Message
- Includes:
- Extension::ToJson
- Defined in:
- lib/komonjo/models/message.rb
Overview
slacke Message
Instance Attribute Summary collapse
-
#channel ⇒ Object
Returns the value of attribute channel.
-
#edited ⇒ Object
Returns the value of attribute edited.
-
#markdown ⇒ Object
readonly
for jsonize.
-
#subtype ⇒ Object
Returns the value of attribute subtype.
-
#text ⇒ Object
Returns the value of attribute text.
-
#ts ⇒ Object
Returns the value of attribute ts.
-
#type ⇒ Object
Returns the value of attribute type.
-
#user ⇒ Object
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
- #first_partial_message ⇒ Object
- #icon_markdown ⇒ Object
- #name_markdown ⇒ Object
- #partial_messages ⇒ Object
- #text_markdown ⇒ Object
- #timestamp ⇒ Object
- #to_json(*args) ⇒ Object
- #to_json_org ⇒ Object
- #to_markdown ⇒ Object
- #ts_markdown ⇒ Object
Instance Attribute Details
#channel ⇒ Object
Returns the value of attribute channel.
6 7 8 |
# File 'lib/komonjo/models/message.rb', line 6 def channel @channel end |
#edited ⇒ Object
Returns the value of attribute edited.
6 7 8 |
# File 'lib/komonjo/models/message.rb', line 6 def edited @edited end |
#markdown ⇒ Object (readonly)
for jsonize
8 9 10 |
# File 'lib/komonjo/models/message.rb', line 8 def markdown @markdown end |
#subtype ⇒ Object
Returns the value of attribute subtype.
6 7 8 |
# File 'lib/komonjo/models/message.rb', line 6 def subtype @subtype end |
#text ⇒ Object
Returns the value of attribute text.
6 7 8 |
# File 'lib/komonjo/models/message.rb', line 6 def text @text end |
#ts ⇒ Object
Returns the value of attribute ts.
6 7 8 |
# File 'lib/komonjo/models/message.rb', line 6 def ts @ts end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/komonjo/models/message.rb', line 6 def type @type end |
#user ⇒ Object
Returns the value of attribute user.
6 7 8 |
# File 'lib/komonjo/models/message.rb', line 6 def user @user end |
Class Method Details
.create(hash) ⇒ Object
11 12 13 14 15 |
# File 'lib/komonjo/models/message.rb', line 11 def self.create(hash) new.tap do |e| hash.each { |k, v| e.instance_variable_set("@#{k}", v) } end end |
Instance Method Details
#first_partial_message ⇒ Object
30 31 32 |
# File 'lib/komonjo/models/message.rb', line 30 def @first_partial_message ||= PartialMessageFactory.build(text) end |
#icon_markdown ⇒ Object
42 43 44 |
# File 'lib/komonjo/models/message.rb', line 42 def icon_markdown "* ![#{@user.name} icon](#{@user.profile.image_48})\n" end |
#name_markdown ⇒ Object
46 47 48 |
# File 'lib/komonjo/models/message.rb', line 46 def name_markdown "\t- #{@user.name}\n" end |
#partial_messages ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/komonjo/models/message.rb', line 17 def @partial_messages ||= begin ret = [] tmp = while tmp ret << tmp tmp = tmp.next end ret end end |
#text_markdown ⇒ Object
54 55 56 57 |
# File 'lib/komonjo/models/message.rb', line 54 def text_markdown t = .map(&:markdown).join "\t- #{t}\n" end |
#timestamp ⇒ Object
34 35 36 |
# File 'lib/komonjo/models/message.rb', line 34 def Time.at(@ts.to_f).strftime('%Y-%m-%d %H:%M:%S') end |
#to_json(*args) ⇒ Object
59 60 61 62 |
# File 'lib/komonjo/models/message.rb', line 59 def to_json(*args) @markdown = to_markdown to_json_org(args) end |
#to_json_org ⇒ Object
9 |
# File 'lib/komonjo/models/message.rb', line 9 alias to_json_org to_json |
#to_markdown ⇒ Object
38 39 40 |
# File 'lib/komonjo/models/message.rb', line 38 def to_markdown icon_markdown + name_markdown + ts_markdown + text_markdown end |
#ts_markdown ⇒ Object
50 51 52 |
# File 'lib/komonjo/models/message.rb', line 50 def ts_markdown "\t- #{}\n" end |