Class: ReadmeScore::Document::Metrics
- Inherits:
-
Object
- Object
- ReadmeScore::Document::Metrics
- Defined in:
- lib/readme-score/document/metrics.rb
Constant Summary collapse
- EQUATION_METRICS =
[ :cumulative_code_block_length ]
Instance Method Summary collapse
- #code_block_to_paragraph_ratio ⇒ Object
- #cumulative_code_block_length ⇒ Object
- #has_gifs? ⇒ Boolean
- #has_images? ⇒ Boolean
- #has_lists? ⇒ Boolean
- #has_tables? ⇒ Boolean
-
#initialize(noko_or_html) ⇒ Metrics
constructor
A new instance of Metrics.
- #inspect ⇒ Object
- #number_of_code_blocks ⇒ Object
- #number_of_external_links ⇒ Object
- #number_of_gifs ⇒ Object
- #number_of_images ⇒ Object
- #number_of_internal_links ⇒ Object
- #number_of_links ⇒ Object
- #number_of_non_code_sections ⇒ Object
- #number_of_paragraphs ⇒ Object
Constructor Details
Instance Method Details
#code_block_to_paragraph_ratio ⇒ Object
31 32 33 34 35 36 |
# File 'lib/readme-score/document/metrics.rb', line 31 def code_block_to_paragraph_ratio if number_of_paragraphs.to_f == 0.0 return 0 end number_of_code_blocks.to_f / number_of_paragraphs.to_f end |
#cumulative_code_block_length ⇒ Object
11 12 13 |
# File 'lib/readme-score/document/metrics.rb', line 11 def cumulative_code_block_length all_code_blocks.inner_html.length end |
#has_gifs? ⇒ Boolean
62 63 64 |
# File 'lib/readme-score/document/metrics.rb', line 62 def has_gifs? number_of_gifs > 0 end |
#has_images? ⇒ Boolean
54 55 56 |
# File 'lib/readme-score/document/metrics.rb', line 54 def has_images? number_of_images > 0 end |
#has_lists? ⇒ Boolean
50 51 52 |
# File 'lib/readme-score/document/metrics.rb', line 50 def has_lists? all_lists.length > 0 end |
#has_tables? ⇒ Boolean
70 71 72 |
# File 'lib/readme-score/document/metrics.rb', line 70 def has_tables? !all_tables.empty? end |
#inspect ⇒ Object
74 75 76 |
# File 'lib/readme-score/document/metrics.rb', line 74 def inspect "#<#{self.class}>" end |
#number_of_code_blocks ⇒ Object
19 20 21 |
# File 'lib/readme-score/document/metrics.rb', line 19 def number_of_code_blocks all_code_blocks.length end |
#number_of_external_links ⇒ Object
44 45 46 47 48 |
# File 'lib/readme-score/document/metrics.rb', line 44 def number_of_external_links all_links.reject {|a| internal_link?(a) }.count end |
#number_of_gifs ⇒ Object
66 67 68 |
# File 'lib/readme-score/document/metrics.rb', line 66 def number_of_gifs all_gifs.length end |
#number_of_images ⇒ Object
58 59 60 |
# File 'lib/readme-score/document/metrics.rb', line 58 def number_of_images all_images.count end |
#number_of_internal_links ⇒ Object
38 39 40 41 42 |
# File 'lib/readme-score/document/metrics.rb', line 38 def number_of_internal_links all_links.select {|a| internal_link?(a) }.count end |
#number_of_links ⇒ Object
15 16 17 |
# File 'lib/readme-score/document/metrics.rb', line 15 def number_of_links all_links.length end |
#number_of_non_code_sections ⇒ Object
27 28 29 |
# File 'lib/readme-score/document/metrics.rb', line 27 def number_of_non_code_sections (all_paragraphs + all_lists).length end |
#number_of_paragraphs ⇒ Object
23 24 25 |
# File 'lib/readme-score/document/metrics.rb', line 23 def number_of_paragraphs all_paragraphs.length end |