Class: Twoffein::Profile

Inherits:
Struct
  • Object
show all
Defined in:
lib/twoffein-client/profile.rb,
lib/twoffein-client/profile.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = nil) ⇒ Profile

Returns a new instance of Profile.



18
19
20
21
# File 'lib/twoffein-client/profile.rb', line 18

def initialize(hash=nil)
  return super(*hash) if hash.nil?
  hash.each { |key,val| self[key] = val if members.include? key }
end

Instance Attribute Details

#bluttwoffeinkonzentrationObject

Returns the value of attribute bluttwoffeinkonzentration

Returns:

  • (Object)

    the current value of bluttwoffeinkonzentration



8
9
10
# File 'lib/twoffein-client/profile.rb', line 8

def bluttwoffeinkonzentration
  @bluttwoffeinkonzentration
end

#drinkObject

Returns the value of attribute drink

Returns:

  • (Object)

    the current value of drink



8
9
10
# File 'lib/twoffein-client/profile.rb', line 8

def drink
  @drink
end

#drunkenObject

Returns the value of attribute drunken

Returns:

  • (Object)

    the current value of drunken



8
9
10
# File 'lib/twoffein-client/profile.rb', line 8

def drunken
  @drunken
end

#first_loginObject

Returns the value of attribute first_login

Returns:

  • (Object)

    the current value of first_login



8
9
10
# File 'lib/twoffein-client/profile.rb', line 8

def 
  @first_login
end

#questObject

Returns the value of attribute quest

Returns:

  • (Object)

    the current value of quest



8
9
10
# File 'lib/twoffein-client/profile.rb', line 8

def quest
  @quest
end

#rankObject

Returns the value of attribute rank

Returns:

  • (Object)

    the current value of rank



8
9
10
# File 'lib/twoffein-client/profile.rb', line 8

def rank
  @rank
end

#rank_titleObject

Returns the value of attribute rank_title

Returns:

  • (Object)

    the current value of rank_title



8
9
10
# File 'lib/twoffein-client/profile.rb', line 8

def rank_title
  @rank_title
end

#screen_nameObject

Returns the value of attribute screen_name

Returns:

  • (Object)

    the current value of screen_name



8
9
10
# File 'lib/twoffein-client/profile.rb', line 8

def screen_name
  @screen_name
end

Class Method Details

.get(profile = "") ⇒ Object



23
24
25
# File 'lib/twoffein-client/profile.rb', line 23

def self.get(profile="")
  new(HTTP.get("profile", :profile => profile))
end

Instance Method Details

#to_sObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/twoffein-client/profile.rb', line 27

def to_s
  hash = instance_hash
  max_length = hash.keys.map { |k| k.length }.max

  hash.map { |attr, value|
    attr = attr.to_sym

    if attr == :first_login
      value = human_readable_time(value)
    end

    postfix = ":"
    attr = human_readable_key(attr) + postfix

    "#{attr.to_s.ljust(max_length+postfix.length+1)}#{value}"
  }.join("\n")
end