Class: Glass::TimelineItem
- Inherits:
-
Object
- Object
- Glass::TimelineItem
- Defined in:
- lib/glass/timeline/timeline_item.rb
Overview
Each item in the user’s timeline is represented as a TimelineItem JSON structure, described below.
Defined Under Namespace
Classes: Attachment, MenuItems, Notification
Constant Summary collapse
- DISPLAY_TIME =
"displayTime"- WRITE_TIME =
"writeTime"- @@kind =
MIRROR+"#"+TIMELINE_ITEM
Class Attribute Summary collapse
-
.kind ⇒ Object
readonly
The type of resource.
Instance Attribute Summary collapse
-
#attachments ⇒ Object
A list of media attachments associated with this item.
-
#bundleId ⇒ Object
The bundle ID for this item.
-
#canonicalUrl ⇒ Object
A canonical URL pointing to the canonical/high quality version of the data represented by the timeline item.
-
#client ⇒ Object
readonly
The Client.
-
#created ⇒ Object
readonly
The time at which this item was created, formatted according to RFC 3339.
-
#creator ⇒ Object
The user or group that created this item.
-
#displayTime ⇒ Object
readonly
The time that should be displayed when this item is viewed in the timeline, formatted according to RFC 3339.
-
#etag ⇒ Object
readonly
ETag for this item.
-
#html ⇒ Object
HTML content for this item.
-
#htmlPages ⇒ Object
Additional pages of HTML content associated with this item.
-
#id ⇒ Object
The ID of the timeline item.
-
#inReplyTo ⇒ Object
If this item was generated as a reply to another item, this field will be set to the ID of the item being replied to.
-
#isBundleCover ⇒ Object
Whether this item is a bundle cover.
-
#isDeleted ⇒ Object
When true, indicates this item is deleted, and only the ID property is set.
-
#isPinned ⇒ Object
When true, indicates this item is pinned, which means it’s grouped alongside “active” items like navigation and hangouts, on the opposite side of the home screen from historical (non-pinned) timeline items.
-
#location ⇒ Object
The geographic location associated with this item.
-
#menuItems ⇒ Object
A list of menu items that will be presented to the user when this item is selected in the timeline.
-
#notification ⇒ Object
Controls how notifications for this item are presented on the device.
-
#pinScore ⇒ Object
For pinned items, this determines the order in which the item is displayed in the timeline, with a higher score appearing closer to the clock.
-
#recipients ⇒ Object
A list of contacts or groups that this item has been shared with.
-
#selfLink ⇒ Object
A URL that can be used to retrieve this item.
-
#sourceItemId ⇒ Object
Opaque string you can use to map a timeline item to data in your own service.
-
#speakableText ⇒ Object
The speakable version of the content of this item.
-
#text ⇒ Object
Text content of this item.
-
#title ⇒ Object
The title of this item.
-
#updated ⇒ Object
The time at which this item was last modified, formatted according to RFC 3339.
Class Method Summary collapse
- .get(client, id) ⇒ Object
-
.list(client, params = {}) ⇒ Object
Retrieves a list of timeline items for the authenticated user.
Instance Method Summary collapse
- #file_to_upload ⇒ Object
- #file_upload? ⇒ Boolean
-
#initialize(client = nil) ⇒ TimelineItem
constructor
A new instance of TimelineItem.
-
#insert!(mirror = @client) ⇒ Object
Insert a new Timeline Item in the user’s glass.
Constructor Details
#initialize(client = nil) ⇒ TimelineItem
Returns a new instance of TimelineItem.
10 11 12 |
# File 'lib/glass/timeline/timeline_item.rb', line 10 def initialize(client=nil) @client = client end |
Class Attribute Details
.kind ⇒ Object (readonly)
The type of resource. This is always mirror#timelineItem.
18 19 20 |
# File 'lib/glass/timeline/timeline_item.rb', line 18 def kind @kind end |
Instance Attribute Details
#attachments ⇒ Object
A list of media attachments associated with this item.
131 132 133 |
# File 'lib/glass/timeline/timeline_item.rb', line 131 def @attachments end |
#bundleId ⇒ Object
The bundle ID for this item. Services can specify a bundleId to group many items together. They appear under a single top-level item on the device.
165 166 167 |
# File 'lib/glass/timeline/timeline_item.rb', line 165 def bundleId @bundleId end |
#canonicalUrl ⇒ Object
A canonical URL pointing to the canonical/high quality version of the data represented by the timeline item.
179 180 181 |
# File 'lib/glass/timeline/timeline_item.rb', line 179 def canonicalUrl @canonicalUrl end |
#client ⇒ Object (readonly)
The Client
74 75 76 |
# File 'lib/glass/timeline/timeline_item.rb', line 74 def client @client end |
#created ⇒ Object (readonly)
The time at which this item was created, formatted according to RFC 3339.
87 88 89 |
# File 'lib/glass/timeline/timeline_item.rb', line 87 def created @created end |
#creator ⇒ Object
The user or group that created this item.
110 111 112 |
# File 'lib/glass/timeline/timeline_item.rb', line 110 def creator @creator end |
#displayTime ⇒ Object (readonly)
The time that should be displayed when this item is viewed in the timeline, formatted according to RFC 3339. This user’s timeline is sorted chronologically on display time, so this will also determine where the item is displayed in the timeline. If not set by the service, the display time defaults to the updated time.
98 99 100 |
# File 'lib/glass/timeline/timeline_item.rb', line 98 def displayTime @displayTime end |
#etag ⇒ Object (readonly)
ETag for this item.
106 107 108 |
# File 'lib/glass/timeline/timeline_item.rb', line 106 def etag @etag end |
#html ⇒ Object
HTML content for this item. If both text and html are provided for an item, the html will be rendered in the timeline.
160 161 162 |
# File 'lib/glass/timeline/timeline_item.rb', line 160 def html @html end |
#htmlPages ⇒ Object
Additional pages of HTML content associated with this item. If this field is specified, the item will be displayed as a bundle, with the html field as the cover. It is an error to specify this field without specifying the html field.
171 172 173 |
# File 'lib/glass/timeline/timeline_item.rb', line 171 def htmlPages @htmlPages end |
#id ⇒ Object
The ID of the timeline item. This is unique within a user’s timeline.
79 80 81 |
# File 'lib/glass/timeline/timeline_item.rb', line 79 def id @id end |
#inReplyTo ⇒ Object
If this item was generated as a reply to another item, this field will be set to the ID of the item being replied to. This can be used to attach a reply to the appropriate conversation or post.
116 117 118 |
# File 'lib/glass/timeline/timeline_item.rb', line 116 def inReplyTo @inReplyTo end |
#isBundleCover ⇒ Object
Whether this item is a bundle cover.
If an item is marked as a bundle cover, it will be the entry point to the bundle of items that have the same bundleId as that item. It will be shown only on the main timeline — not within the opened bundle.
On the main timeline, items that are shown are:
Items that have isBundleCover set to true
Items that do not have a bundleId
Items that do not have a bundleId
In a bundle sub-timeline, items that are shown are:
Items that have the bundleId in question AND isBundleCover set to false
195 196 197 |
# File 'lib/glass/timeline/timeline_item.rb', line 195 def isBundleCover @isBundleCover end |
#isDeleted ⇒ Object
When true, indicates this item is deleted, and only the ID property is set.
102 103 104 |
# File 'lib/glass/timeline/timeline_item.rb', line 102 def isDeleted @isDeleted end |
#isPinned ⇒ Object
When true, indicates this item is pinned, which means it’s grouped alongside “active” items like navigation and hangouts, on the opposite side of the home screen from historical (non-pinned) timeline items.
151 152 153 |
# File 'lib/glass/timeline/timeline_item.rb', line 151 def isPinned @isPinned end |
#location ⇒ Object
The geographic location associated with this item.
135 136 137 |
# File 'lib/glass/timeline/timeline_item.rb', line 135 def location @location end |
#menuItems ⇒ Object
A list of menu items that will be presented to the user when this item is selected in the timeline.
139 140 141 |
# File 'lib/glass/timeline/timeline_item.rb', line 139 def @menuItems end |
#notification ⇒ Object
Controls how notifications for this item are presented on the device. If this is missing, no notification will be generated.
144 145 146 |
# File 'lib/glass/timeline/timeline_item.rb', line 144 def notification @notification end |
#pinScore ⇒ Object
For pinned items, this determines the order in which the item is displayed in the timeline, with a higher score appearing closer to the clock. Note: setting this field is currently not supported.
200 201 202 |
# File 'lib/glass/timeline/timeline_item.rb', line 200 def pinScore @pinScore end |
#recipients ⇒ Object
A list of contacts or groups that this item has been shared with.
204 205 206 |
# File 'lib/glass/timeline/timeline_item.rb', line 204 def recipients @recipients end |
#selfLink ⇒ Object
A URL that can be used to retrieve this item.
83 84 85 |
# File 'lib/glass/timeline/timeline_item.rb', line 83 def selfLink @selfLink end |
#sourceItemId ⇒ Object
Opaque string you can use to map a timeline item to data in your own service.
175 176 177 |
# File 'lib/glass/timeline/timeline_item.rb', line 175 def sourceItemId @sourceItemId end |
#speakableText ⇒ Object
The speakable version of the content of this item. Along with the READ_ALOUD menu item, use this field to provide text that would be clearer when read aloud, or to provide extended information to what is displayed visually on Glass.
127 128 129 |
# File 'lib/glass/timeline/timeline_item.rb', line 127 def speakableText @speakableText end |
#text ⇒ Object
Text content of this item.
120 121 122 |
# File 'lib/glass/timeline/timeline_item.rb', line 120 def text @text end |
#title ⇒ Object
The title of this item.
155 156 157 |
# File 'lib/glass/timeline/timeline_item.rb', line 155 def title @title end |
#updated ⇒ Object
The time at which this item was last modified, formatted according to RFC 3339.
91 92 93 |
# File 'lib/glass/timeline/timeline_item.rb', line 91 def updated @updated end |
Class Method Details
.get(client, id) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/glass/timeline/timeline_item.rb', line 21 def get(client, id) client.exexute( :api_method => client.timeline.get, :parameters => {:id => id} ) end |
.list(client, params = {}) ⇒ Object
Retrieves a list of timeline items for the authenticated user.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/glass/timeline/timeline_item.rb', line 50 def list(client, params={}) result=[] parameters = params api_result = client.execute( :api_method => mirror.timeline.list, :parameters => parameters) if api_result.success? data = api_result.data unless data.items.empty? result << data.items parameters[:pageToken]= data.next_page_token result << list(client, parameters) end else puts "An error occurred: #{result.data['error']['message']}" end result end |
Instance Method Details
#file_to_upload ⇒ Object
389 390 391 392 393 394 395 |
# File 'lib/glass/timeline/timeline_item.rb', line 389 def file_to_upload file_to_upload=[] @attachments.each { || file_to_upload << unless .id } file_to_upload end |
#file_upload? ⇒ Boolean
381 382 383 384 385 386 387 |
# File 'lib/glass/timeline/timeline_item.rb', line 381 def file_upload? flag=false @attachments.each { || flag = true unless .id } return flag end |
#insert!(mirror = @client) ⇒ Object
Insert a new Timeline Item in the user’s glass.
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/glass/timeline/timeline_item.rb', line 359 def insert!(mirror=@client) timeline_item = self result = [] if file_upload? for file in file_to_upload media = Google::APIClient::UploadIO.new(file.contentUrl, file.content_type) result << client.execute!( :api_method => mirror.timeline.insert, :body_object => timeline_item, :media => media, :parameters => { :uploadType => 'multipart', :alt => 'json'}) end else result << client.execute( :api_method => mirror.timeline.insert, :body_object => timeline_item) end return result.data end |