Class: Komonjo::Model::PartialMessage
- Inherits:
-
Object
- Object
- Komonjo::Model::PartialMessage
- Defined in:
- lib/komonjo/models/partial_message.rb
Instance Attribute Summary collapse
-
#filters ⇒ Object
Returns the value of attribute filters.
-
#markdown ⇒ Object
Returns the value of attribute markdown.
-
#next ⇒ Object
Returns the value of attribute next.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #embed ⇒ Object
-
#initialize(text, filters) ⇒ PartialMessage
constructor
A new instance of PartialMessage.
- #parse ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(text, filters) ⇒ PartialMessage
Returns a new instance of PartialMessage.
9 10 11 12 13 14 |
# File 'lib/komonjo/models/partial_message.rb', line 9 def initialize(text, filters) @text = text @markdown = text @filters = filters parse end |
Instance Attribute Details
#filters ⇒ Object
Returns the value of attribute filters.
7 8 9 |
# File 'lib/komonjo/models/partial_message.rb', line 7 def filters @filters end |
#markdown ⇒ Object
Returns the value of attribute markdown.
5 6 7 |
# File 'lib/komonjo/models/partial_message.rb', line 5 def markdown @markdown end |
#next ⇒ Object
Returns the value of attribute next.
4 5 6 |
# File 'lib/komonjo/models/partial_message.rb', line 4 def next @next end |
#text ⇒ Object
Returns the value of attribute text.
6 7 8 |
# File 'lib/komonjo/models/partial_message.rb', line 6 def text @text end |
Instance Method Details
#embed ⇒ Object
52 53 |
# File 'lib/komonjo/models/partial_message.rb', line 52 def (*) end |
#parse ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/komonjo/models/partial_message.rb', line 16 def parse f = filters.find { |e| e.match(text) } return unless f arr = f.parse(text) case arr.size when 1 a, = arr @text = a[:text] extend f.mixin when 2 a, b = arr @text = a[:text] if a[:matched] extend f.mixin @next = PartialMessage.new(b[:text], filters) @next.parse else @next = PartialMessage.new(b[:text], filters).tap do |e| e.extend f.mixin end end when 3 a, b, c = arr @text = a[:text] @next = PartialMessage.new(b[:text], filters).tap do |e| e.extend f.mixin e.next = PartialMessage.new(c[:text], filters).tap(&:parse) end end self end |
#type ⇒ Object
48 49 50 |
# File 'lib/komonjo/models/partial_message.rb', line 48 def type :text end |