Class: Ayadn::Profile
- Inherits:
-
Object
- Object
- Ayadn::Profile
- Defined in:
- lib/ayadn/profile.rb
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 |
# File 'lib/ayadn/profile.rb', line 7 def initialize abort(Status.) if .empty? = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/ayadn/profile.rb', line 5 def 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
22 23 24 25 26 27 28 29 |
# File 'lib/ayadn/profile.rb', line 22 def get_text_from_user unless [:delete] || [:avatar] || [:cover] writer = Post.new input = writer.compose() writer.check_post_length(input) @text = input.join("\n") end end |
#prepare_payload ⇒ Object
31 32 33 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 |
# File 'lib/ayadn/profile.rb', line 31 def prepare_payload @payload = \ if [:bio] if [:delete] {'description' => {'text' => ''}} else {'description' => {'text' => @text}} end elsif [:name] if [:delete] abort("'Delete' isn't available for 'name'.\n".color(:red)) else {'name' => @text} end elsif [:twitter] if [:delete] {'annotations' => [{'type' => 'net.app.core.directory.twitter'}]} else {'annotations' => [{ 'type' => 'net.app.core.directory.twitter', 'value' => {'username' => @text}}]} end elsif [:blog] if [:delete] {'annotations' => [{'type' => 'net.app.core.directory.blog'}]} else {'annotations' => [{ 'type' => 'net.app.core.directory.blog', 'value' => {'url' => @text}}]} end elsif [:web] if [:delete] {'annotations' => [{'type' => 'net.app.core.directory.homepage'}]} else {'annotations' => [{ 'type' => 'net.app.core.directory.homepage', 'value' => {'url' => @text}}]} end end end |
#update ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/ayadn/profile.rb', line 12 def update if [:avatar] FileOps.upload_avatar([:avatar].join) elsif [:cover] FileOps.upload_cover([:cover].join) else CNX.patch(Endpoints.new.user('me'), @payload) end end |