Class: Love::Author
- Inherits:
-
Object
- Object
- Love::Author
- Defined in:
- lib/love/author.rb
Instance Attribute Summary collapse
-
#gems ⇒ Object
readonly
Returns the value of attribute gems.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #add_gem(gem) ⇒ Object
- #fetch_info ⇒ Object
-
#initialize(name, fetch = true) ⇒ Author
constructor
A new instance of Author.
Constructor Details
#initialize(name, fetch = true) ⇒ Author
Returns a new instance of Author.
6 7 8 9 10 |
# File 'lib/love/author.rb', line 6 def initialize(name, fetch = true) @name = name @gems = [] fetch_info if fetch end |
Instance Attribute Details
#gems ⇒ Object (readonly)
Returns the value of attribute gems.
4 5 6 |
# File 'lib/love/author.rb', line 4 def gems @gems end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
4 5 6 |
# File 'lib/love/author.rb', line 4 def info @info end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/love/author.rb', line 4 def name @name end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
4 5 6 |
# File 'lib/love/author.rb', line 4 def username @username end |
Instance Method Details
#add_gem(gem) ⇒ Object
34 35 36 |
# File 'lib/love/author.rb', line 34 def add_gem(gem) @gems << gem end |
#fetch_info ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/love/author.rb', line 12 def fetch_info uri = ERB::Util.url_encode(name) puts "search for #{name}" begin search_person = Love.octokit.search_users uri @info = \ if search_person.count > 1 puts '!!! THERE ARE SEVERAL PERSONS WITH THIS NAME IN GITHUB !!!' user_num = pick_user(search_person) Love.octokit.user search_person[user_num].login else Love.octokit.user search_person.first.login end puts "found #{@info.login}" rescue Octokit::Forbidden puts 'github have some unfair limits =(' rescue puts 'not found' end end |