Class: Whisper::Message

Inherits:
Struct
  • Object
show all
Defined in:
lib/whisper/message.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#contentObject

Returns the value of attribute content

Returns:

  • (Object)

    the current value of content



1
2
3
# File 'lib/whisper/message.rb', line 1

def content
  @content
end

#fromObject

Returns the value of attribute from

Returns:

  • (Object)

    the current value of from



1
2
3
# File 'lib/whisper/message.rb', line 1

def from
  @from
end

#has_readObject

Returns the value of attribute has_read

Returns:

  • (Object)

    the current value of has_read



1
2
3
# File 'lib/whisper/message.rb', line 1

def has_read
  @has_read
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



1
2
3
# File 'lib/whisper/message.rb', line 1

def id
  @id
end

#sent_dateObject

Returns the value of attribute sent_date

Returns:

  • (Object)

    the current value of sent_date



1
2
3
# File 'lib/whisper/message.rb', line 1

def sent_date
  @sent_date
end

#star_checkObject

Returns the value of attribute star_check

Returns:

  • (Object)

    the current value of star_check



1
2
3
# File 'lib/whisper/message.rb', line 1

def star_check
  @star_check
end

Class Method Details

.from_hash(hsh) ⇒ Object



6
7
8
9
10
11
# File 'lib/whisper/message.rb', line 6

def self.from_hash(hsh)
  ret = new(hsh['id'].to_i, hsh['from'], hsh['content'], DateTime.parse(hsh['sent_date']))
  ret.has_read = hsh['hasRead'].to_s == 'yes'
  ret.star_check = hsh['starCheck'].to_s == 'yes'
  ret
end

.parse_collection(xml) ⇒ Object



2
3
4
# File 'lib/whisper/message.rb', line 2

def self.parse_collection(xml)
  Hash.from_xml(xml)['messages'].map{|hsh| from_hash(hsh)}
end