Class: E621::Set

Inherits:
Container show all
Defined in:
lib/set.rb

Instance Method Summary collapse

Methods inherited from Container

#method_missing

Constructor Details

#initialize(post) ⇒ Set

Returns a new instance of Set.



22
23
24
# File 'lib/set.rb', line 22

def initialize(post)
  set_variables(post)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class E621::Container

Instance Method Details

#add_post(id) ⇒ Object



26
27
28
29
# File 'lib/set.rb', line 26

def add_post(id)
  api = API.new("set")
  api.post("add_post",{"post_id"=>id,"set_id"=>@id})
end

#keys ⇒ Object



31
32
33
# File 'lib/set.rb', line 31

def keys
  return instance_variables.map{|i|i.to_s.sub("@","")}
end

#to_json ⇒ Object



35
36
37
38
39
40
41
# File 'lib/set.rb', line 35

def to_json
  json_hash = Hash.new
  instance_variables.each do |i|
    json_hash.store(i.to_s.sub("@",""),instance_variable_get(i))
  end
  return json_hash.to_json
end