Class: Votifier::Vote

Inherits:
Object
  • Object
show all
Defined in:
lib/votifier/vote.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service_name, username, ip_address, timestamp) ⇒ Vote

Returns a new instance of Vote.



5
6
7
8
9
10
# File 'lib/votifier/vote.rb', line 5

def initialize(service_name, username, ip_address, timestamp)
  @service_name = service_name
  @username = username
  @ip_address = ip_address
  @timestamp = timestamp
end

Instance Attribute Details

#ip_addressObject (readonly)

Returns the value of attribute ip_address.



3
4
5
# File 'lib/votifier/vote.rb', line 3

def ip_address
  @ip_address
end

#service_nameObject (readonly)

Returns the value of attribute service_name.



3
4
5
# File 'lib/votifier/vote.rb', line 3

def service_name
  @service_name
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



3
4
5
# File 'lib/votifier/vote.rb', line 3

def timestamp
  @timestamp
end

#usernameObject (readonly)

Returns the value of attribute username.



3
4
5
# File 'lib/votifier/vote.rb', line 3

def username
  @username
end

Class Method Details

.from_array(vote_info) ⇒ Object



12
13
14
15
16
# File 'lib/votifier/vote.rb', line 12

def self.from_array(vote_info)
  opcode, service_name, username, ip_address, timestamp, empty_space = vote_info
  vote = Vote.new(service_name, username, ip_address, timestamp)
  vote
end

Instance Method Details

#to_hObject



18
19
20
21
22
23
24
25
# File 'lib/votifier/vote.rb', line 18

def to_h
  {
    :service_name => service_name,
    :username => username,
    :ip_address => ip_address,
    :timestamp => timestamp
  }
end