Class: Mona::Response
- Inherits:
-
Object
- Object
- Mona::Response
- Defined in:
- lib/mona/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#name ⇒ Object
Returns the value of attribute name.
-
#trip ⇒ Object
Returns the value of attribute trip.
-
#written_at ⇒ Object
Returns the value of attribute written_at.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(options) ⇒ Response
Returns a new instance of Response.
6 7 8 9 10 |
# File 'lib/mona/response.rb', line 6 def initialize() .each do |key, value| self.send("#{key}=", value) end end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
5 6 7 |
# File 'lib/mona/response.rb', line 5 def body @body end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/mona/response.rb', line 5 def name @name end |
#trip ⇒ Object
Returns the value of attribute trip.
5 6 7 |
# File 'lib/mona/response.rb', line 5 def trip @trip end |
#written_at ⇒ Object
Returns the value of attribute written_at.
5 6 7 |
# File 'lib/mona/response.rb', line 5 def written_at @written_at end |
Class Method Details
.parse_line(line) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/mona/response.rb', line 13 def parse_line(line) name, _, time_str, body, _ = line.to_s.split(/<>/) name, trip = parse_name(name) time = Time.parse(time_str + " +09:00") body = body.strip.split(' <br> ').join("\n") Mona::Response.new(name: name, trip: trip, written_at: time, body: body) end |
.parse_name(name) ⇒ Object
21 22 23 24 25 |
# File 'lib/mona/response.rb', line 21 def parse_name(name) name, trip = name.split(/ <\/b>/) trip = trip.match(/\w+/)[0] if trip [name, trip] end |