Class: HangoutsJsonParser::Attachment::Location
- Inherits:
-
Attachment
- Object
- Attachment
- HangoutsJsonParser::Attachment::Location
- Defined in:
- lib/hangouts_json_parser/attachment/location.rb
Overview
A location attachment
Instance Attribute Summary collapse
-
#url ⇒ String
readonly
Url to the location on Google Maps.
Class Method Summary collapse
-
.from_message_attachment(data) ⇒ Location
Creates a Location from message data.
-
.type ⇒ Array
Type identifier of this attachment.
Instance Method Summary collapse
-
#initialize(url) ⇒ Location
constructor
A new instance of Location.
Constructor Details
#initialize(url) ⇒ Location
Returns a new instance of Location.
11 12 13 |
# File 'lib/hangouts_json_parser/attachment/location.rb', line 11 def initialize url @url = url end |
Instance Attribute Details
#url ⇒ String (readonly)
Returns url to the location on Google Maps.
9 10 11 |
# File 'lib/hangouts_json_parser/attachment/location.rb', line 9 def url @url end |
Class Method Details
.from_message_attachment(data) ⇒ Location
Creates a Location from message data
18 19 20 21 22 |
# File 'lib/hangouts_json_parser/attachment/location.rb', line 18 def self. data raise "Attachment passed is not a location" unless data.dig("embed_item", "type").eql? Location.type Location.new data.dig("embed_item", "id") end |
.type ⇒ Array
Returns type identifier of this attachment.
25 26 27 |
# File 'lib/hangouts_json_parser/attachment/location.rb', line 25 def self.type ["PLACE_V2", "THING_V2", "THING"] end |