Class: Oksky::Chat::Object::MessagesResource

Inherits:
Base
  • Object
show all
Defined in:
lib/oksky/chat/object/messages_resource.rb

Instance Method Summary collapse

Methods inherited from Base

#[], #initialize

Constructor Details

This class inherits a constructor from Oksky::Chat::Object::Base

Instance Method Details

#contentString<Oksky::Chat::Event::Message>

Returns:

  • (String<Oksky::Chat::Event::Message>)


30
31
32
# File 'lib/oksky/chat/object/messages_resource.rb', line 30

def content
  content_value('content')
end

#created_atTime<Oksky::Chat::Event::Message>

Returns:

  • (Time<Oksky::Chat::Event::Message>)


64
65
66
# File 'lib/oksky/chat/object/messages_resource.rb', line 64

def created_at
  content_value("created_at")
end

#created_at_unixTime<Oksky::Chat::Event::Message>

Returns:

  • (Time<Oksky::Chat::Event::Message>)


79
80
81
# File 'lib/oksky/chat/object/messages_resource.rb', line 79

def created_at_unix
  content_value("created_at_unix")
end

#deleted_atTime<Oksky::Chat::Event::Message>

Returns:

  • (Time<Oksky::Chat::Event::Message>)


69
70
71
# File 'lib/oksky/chat/object/messages_resource.rb', line 69

def deleted_at
  content_value("deleted_at")
end

#deleted_at_unixTime<Oksky::Chat::Event::Message>

Returns:

  • (Time<Oksky::Chat::Event::Message>)


84
85
86
# File 'lib/oksky/chat/object/messages_resource.rb', line 84

def deleted_at_unix
  content_value("deleted_at_unix")
end

#idObject



25
26
27
# File 'lib/oksky/chat/object/messages_resource.rb', line 25

def id
  @src.dig("id")
end

#infoHash<Oksky::Chat::Event::Message>

Returns:

  • (Hash<Oksky::Chat::Event::Message>)


54
55
56
# File 'lib/oksky/chat/object/messages_resource.rb', line 54

def info
  content_value("info")
end

#kindString<Oksky::Chat::Event::MessageKind::>

Returns:

  • (String<Oksky::Chat::Event::MessageKind::>)


35
36
37
38
39
40
41
# File 'lib/oksky/chat/object/messages_resource.rb', line 35

def kind
  begin
    Oksky::Chat::Object::MessagesResourceKind.const_get(content_value("kind").split("_").map{|w| w[0] = w[0].capitalize; w}.join)
  rescue NameError => e
    Oksky::Chat::Object::MessagesResourceKind::Unsupport
  end
end

#messageObject



103
104
105
106
107
108
109
# File 'lib/oksky/chat/object/messages_resource.rb', line 103

def message
  if @src.has_key?('attributes')
    @src['attributes']
  else
    @src
  end
end

#relationshipsObject



119
120
121
122
123
124
125
# File 'lib/oksky/chat/object/messages_resource.rb', line 119

def relationships
  if exist_relationships?
    return @src['relationships']
  else
    {}
  end
end

#room_idObject



111
112
113
# File 'lib/oksky/chat/object/messages_resource.rb', line 111

def room_id
  @src.dig("relationships", "room", "data", "id")
end

#roomnameString<Oksky::Chat::Event::Message>

Returns:

  • (String<Oksky::Chat::Event::Message>)


99
100
101
# File 'lib/oksky/chat/object/messages_resource.rb', line 99

def roomname
  content_value("roomname")
end

#settingsHash<Oksky::Chat::Event::Message>

Returns:

  • (Hash<Oksky::Chat::Event::Message>)


44
45
46
# File 'lib/oksky/chat/object/messages_resource.rb', line 44

def settings
  content_value("settings")
end

#statusString<Oksky::Chat::Event::Message>

Returns:

  • (String<Oksky::Chat::Event::Message>)


49
50
51
# File 'lib/oksky/chat/object/messages_resource.rb', line 49

def status
  content_value("status")
end

#tagsArray<Oksky::Chat::Event::Message>

Returns:

  • (Array<Oksky::Chat::Event::Message>)


59
60
61
# File 'lib/oksky/chat/object/messages_resource.rb', line 59

def tags
  content_value("tags")
end

#updated_atTime<Oksky::Chat::Event::Message>

Returns:

  • (Time<Oksky::Chat::Event::Message>)


74
75
76
# File 'lib/oksky/chat/object/messages_resource.rb', line 74

def updated_at
  content_value("updated_at")
end

#user_idObject



115
116
117
# File 'lib/oksky/chat/object/messages_resource.rb', line 115

def user_id
  @src.dig("relationships", "user", "data", "id")
end

#user_is_guestBoolean<Oksky::Chat::Event::Message>

Returns:

  • (Boolean<Oksky::Chat::Event::Message>)


94
95
96
# File 'lib/oksky/chat/object/messages_resource.rb', line 94

def user_is_guest
  content_value("user_is_guest")
end

#usernameString<Oksky::Chat::Event::Message>

Returns:

  • (String<Oksky::Chat::Event::Message>)


89
90
91
# File 'lib/oksky/chat/object/messages_resource.rb', line 89

def username
  content_value("username")
end