Class: User

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_id:, labels: nil, comment: nil) ⇒ User

Returns a new instance of User.



55
56
57
58
59
# File 'lib/gorse.rb', line 55

def initialize(user_id:, labels: nil, comment: nil)
  @user_id = user_id
  @labels = labels
  @comment = comment
end

Instance Attribute Details

#commentObject (readonly)

Returns the value of attribute comment.



74
75
76
# File 'lib/gorse.rb', line 74

def comment
  @comment
end

#labelsObject (readonly)

Returns the value of attribute labels.



74
75
76
# File 'lib/gorse.rb', line 74

def labels
  @labels
end

#user_idObject (readonly)

Returns the value of attribute user_id.



74
75
76
# File 'lib/gorse.rb', line 74

def user_id
  @user_id
end

Class Method Details

.from_json(string) ⇒ Object



69
70
71
72
# File 'lib/gorse.rb', line 69

def self.from_json(string)
  h = JSON.load string
  User.new(user_id: h['UserId'], labels: h['Labels'], comment: h['Comment'])
end

Instance Method Details

#to_hObject



61
62
63
# File 'lib/gorse.rb', line 61

def to_h
  { 'UserId' => @user_id, 'Labels' => @labels, 'Comment' => @comment }
end

#to_json(*_args) ⇒ Object



65
66
67
# File 'lib/gorse.rb', line 65

def to_json(*_args)
  JSON.generate(to_h)
end