Class: ReadmeScore::Document
- Inherits:
-
Object
- Object
- ReadmeScore::Document
- Defined in:
- lib/readme-score/document.rb,
lib/readme-score/document/score.rb,
lib/readme-score/document/filter.rb,
lib/readme-score/document/loader.rb,
lib/readme-score/document/parser.rb,
lib/readme-score/document/metrics.rb,
lib/readme-score/document/loader/github_readme_finder.rb
Defined Under Namespace
Classes: Filter, Loader, Metrics, Parser, Score
Instance Attribute Summary collapse
-
#filter ⇒ Object
Returns the value of attribute filter.
-
#html ⇒ Object
Returns the value of attribute html.
-
#metrics ⇒ Object
Returns the value of attribute metrics.
Class Method Summary collapse
Instance Method Summary collapse
-
#html_for_analysis ⇒ String
HTML string ready for analysis.
-
#initialize(html) ⇒ Document
constructor
A new instance of Document.
- #inspect ⇒ Object
- #score ⇒ Object
Constructor Details
#initialize(html) ⇒ Document
Returns a new instance of Document.
17 18 19 20 21 |
# File 'lib/readme-score/document.rb', line 17 def initialize(html) @html = html @noko = Nokogiri::HTML.fragment(@html) @metrics = Document::Metrics.new(html_for_analysis) end |
Instance Attribute Details
#filter ⇒ Object
Returns the value of attribute filter.
9 10 11 |
# File 'lib/readme-score/document.rb', line 9 def filter @filter end |
#html ⇒ Object
Returns the value of attribute html.
9 10 11 |
# File 'lib/readme-score/document.rb', line 9 def html @html end |
#metrics ⇒ Object
Returns the value of attribute metrics.
9 10 11 |
# File 'lib/readme-score/document.rb', line 9 def metrics @metrics end |
Class Method Details
.load(url) ⇒ Object
11 12 13 14 15 |
# File 'lib/readme-score/document.rb', line 11 def self.load(url) loader = Loader.new(url) loader.load! new(loader.html) end |
Instance Method Details
#html_for_analysis ⇒ String
Returns HTML string ready for analysis.
24 25 26 27 |
# File 'lib/readme-score/document.rb', line 24 def html_for_analysis @filter ||= Document::Filter.new(@noko) @filter.filtered_html! end |
#inspect ⇒ Object
33 34 35 |
# File 'lib/readme-score/document.rb', line 33 def inspect "#<#{self.class}>" end |
#score ⇒ Object
29 30 31 |
# File 'lib/readme-score/document.rb', line 29 def score @score ||= Score.new(metrics) end |