Class: Binford::RubyToolbox
- Inherits:
-
WebService
- Object
- WebService
- Binford::RubyToolbox
- Defined in:
- lib/binford/ruby_toolbox.rb
Instance Attribute Summary collapse
-
#gem ⇒ Object
readonly
Returns the value of attribute gem.
Instance Method Summary collapse
- #data ⇒ Object
- #description ⇒ Object
- #document ⇒ Object
-
#initialize(gem) ⇒ RubyToolbox
constructor
A new instance of RubyToolbox.
- #score ⇒ Object
Methods inherited from WebService
Constructor Details
#initialize(gem) ⇒ RubyToolbox
Returns a new instance of RubyToolbox.
7 8 9 10 |
# File 'lib/binford/ruby_toolbox.rb', line 7 def initialize(gem) super("https://www.ruby-toolbox.com/", serializer: Serializers::HTML.new) @gem = gem end |
Instance Attribute Details
#gem ⇒ Object (readonly)
Returns the value of attribute gem.
5 6 7 |
# File 'lib/binford/ruby_toolbox.rb', line 5 def gem @gem end |
Instance Method Details
#data ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/binford/ruby_toolbox.rb', line 12 def data { name: gem, score: score, description: description } end |
#description ⇒ Object
24 25 26 |
# File 'lib/binford/ruby_toolbox.rb', line 24 def description @description ||= document&.xpath("/html/body/section/div/section/div/div[4]/div")&.text end |
#document ⇒ Object
28 29 30 |
# File 'lib/binford/ruby_toolbox.rb', line 28 def document @document ||= get("/projects/#{gem}") end |
#score ⇒ Object
20 21 22 |
# File 'lib/binford/ruby_toolbox.rb', line 20 def score @score ||= document&.xpath("/html/body/section/div/section/div/div[1]/div[2]/div[1]/span[2]")&.text&.to_f end |