Class: Jiralicious::Avatar
- Defined in:
- lib/jiralicious/avatar.rb
Overview
Avatars in the Project class.
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.system(key, options = {}) ⇒ Object
Gets a list of available avatars.
-
.temporary(key, options = {}) ⇒ Object
Creates temporary avatar.
-
.temporary_crop(key, options = {}) ⇒ Object
Updates the cropping on a temporary avatar.
Instance Method Summary collapse
-
#initialize(decoded_json = nil) ⇒ Avatar
constructor
Initialization Method.
Methods inherited from Base
#all, #endpoint_name, endpoint_name, fetch, find, find_all, handler, issueKey_test, #loaded?, #method_missing, #numeric?, parent_name, #parent_name, #properties_from_hash, #reload
Methods included from Parsers::FieldParser
Constructor Details
#initialize(decoded_json = nil) ⇒ Avatar
Initialization Method
- Arguments
-
:decoded_json (optional) decoded json object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/jiralicious/avatar.rb', line 14 def initialize(decoded_json = nil) @loaded = false if !decoded_json.nil? if decoded_json.is_a? Hash decoded_json = properties_from_hash(decoded_json) super(decoded_json) parse!(decoded_json) self.each do |k, v| if v.is_a? Hash self[k] = self.class.new(v) elsif v.is_a? Array v.each_index do |i| if v[i].is_a? Hash v[i] = self.class.new(v[i]) end end self[k] = v end end @loaded = true else i = 0; decoded_json.each do |list| if !list['id'].nil? if numeric? list['id'] id = :"id_#{list['id']}" else id = :"#{list['id']}" end else id = :"_#{i}" i += 1 end self.class.property id self[id] = self.class.new(list) end end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Jiralicious::Base
Class Method Details
.system(key, options = {}) ⇒ Object
Gets a list of available avatars
- Arguments
-
:key (required) avatar type = Project or User
62 63 64 65 |
# File 'lib/jiralicious/avatar.rb', line 62 def system(key, = {}) response = fetch({:method => :get, :key => "#{key}/system", :body => }) return self.new(response.parsed_response) end |
.temporary(key, options = {}) ⇒ Object
Creates temporary avatar
- Arguments
-
:key (required) avatar type = Project or User
:filename (required) file to upload
:size (required) size of the file
77 78 79 80 |
# File 'lib/jiralicious/avatar.rb', line 77 def temporary(key, = {}) response = fetch({:method => :post, :key => "#{key}/temporary", :body => }) return self.new(response.parsed_response) end |
.temporary_crop(key, options = {}) ⇒ Object
Updates the cropping on a temporary avatar
- Arguments
-
:key (required) avatar type = Project or User
:cropperWidth (optional) width of the image
:cropperOffsetX (optional) X Offset on image
:cropperOffsety (optional) Y Offset on image
:needsCropping (optional) Boolean if needs cropping
96 97 98 |
# File 'lib/jiralicious/avatar.rb', line 96 def temporary_crop(key, = {}) response = fetch({:method => :post, :key => "#{key}/temporaryCrop", :body => }) end |