Class: Ayadn::Profile
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #get_text_from_user ⇒ Object
-
#initialize(options) ⇒ Profile
constructor
A new instance of Profile.
- #prepare_payload ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(options) ⇒ Profile
Returns a new instance of Profile.
7 8 9 10 11 12 13 |
# File 'lib/ayadn/profile.rb', line 7 def initialize if .empty? @status. exit end @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/ayadn/profile.rb', line 5 def @options end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
5 6 7 |
# File 'lib/ayadn/profile.rb', line 5 def payload @payload end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
5 6 7 |
# File 'lib/ayadn/profile.rb', line 5 def text @text end |
Instance Method Details
#get_text_from_user ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/ayadn/profile.rb', line 25 def get_text_from_user unless @options[:delete] || @options[:avatar] || @options[:cover] writer = Post.new input = writer.compose() @text = input.join("\n") writer.post_size_error(@text) if writer.post_size_ok?(@text) == false end end |
#prepare_payload ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/ayadn/profile.rb', line 34 def prepare_payload @payload = \ if @options[:bio] if @options[:delete] {'description' => {'text' => ''}} else {'description' => {'text' => @text}} end elsif @options[:name] if @options[:delete] abort("'Delete' isn't available for 'name'.\n".color(:red)) else {'name' => @text} end elsif @options[:twitter] if @options[:delete] {'annotations' => [{'type' => 'net.app.core.directory.twitter'}]} else {'annotations' => [{ 'type' => 'net.app.core.directory.twitter', 'value' => {'username' => @text}}]} end elsif @options[:blog] if @options[:delete] {'annotations' => [{'type' => 'net.app.core.directory.blog'}]} else {'annotations' => [{ 'type' => 'net.app.core.directory.blog', 'value' => {'url' => @text}}]} end elsif @options[:web] if @options[:delete] {'annotations' => [{'type' => 'net.app.core.directory.homepage'}]} else {'annotations' => [{ 'type' => 'net.app.core.directory.homepage', 'value' => {'url' => @text}}]} end end end |
#update ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/ayadn/profile.rb', line 15 def update if @options[:avatar] FileOps.upload_avatar(@options[:avatar].join) elsif @options[:cover] FileOps.upload_cover(@options[:cover].join) else CNX.patch(Endpoints.new.user('me'), @payload) end end |