Class: Beanie::BeanieAlert

Inherits:
Api
  • Object
show all
Defined in:
lib/beanie/beanie_alert.rb

Constant Summary collapse

STATE_NEW =
0
STATE_READ =
1
STATE_ARCHIVED =
2
STATE_NAMES =
[
  ["New (Unread)", STATE_NEW],
  ["Acknowledged (Read)", STATE_READ],
  ["Archived", STATE_ARCHIVED]
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Api

all, build_url, #construct_path, delete, #extract, #field_name, find, get, #object_name, #populate, post, put, #save!, set_headers

Constructor Details

#initializeBeanieAlert

Initialize instance variables



46
47
48
49
50
51
52
# File 'lib/beanie/beanie_alert.rb', line 46

def initialize
  @id = nil
  @state = nil
  @message = nil
  @url = nil
  @member_id = nil
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



32
33
34
# File 'lib/beanie/beanie_alert.rb', line 32

def id
  @id
end

#member_idObject

Returns the value of attribute member_id.



32
33
34
# File 'lib/beanie/beanie_alert.rb', line 32

def member_id
  @member_id
end

#messageObject

Returns the value of attribute message.



32
33
34
# File 'lib/beanie/beanie_alert.rb', line 32

def message
  @message
end

#stateObject

Returns the value of attribute state.



32
33
34
# File 'lib/beanie/beanie_alert.rb', line 32

def state
  @state
end

#urlObject

Returns the value of attribute url.



32
33
34
# File 'lib/beanie/beanie_alert.rb', line 32

def url
  @url
end

Instance Method Details

#state_nameObject

Printable form of the state name



56
57
58
# File 'lib/beanie/beanie_alert.rb', line 56

def state_name
  STATE_NAMES[state][0]
end

#unread?Boolean

Is this an unread message?

Returns:

  • (Boolean)


62
63
64
# File 'lib/beanie/beanie_alert.rb', line 62

def unread?
  state == STATE_NEW
end