Class: Zemanta::Markup
- Inherits:
-
Object
- Object
- Zemanta::Markup
- Defined in:
- lib/zemanta/markup.rb,
lib/zemanta/markup/link.rb,
lib/zemanta/markup/link/target.rb
Defined Under Namespace
Classes: Link
Instance Attribute Summary collapse
-
#links ⇒ Object
readonly
Returns the value of attribute links.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
- #drop_links_below(relevance, confidence) ⇒ Object
-
#initialize(opts = {}) ⇒ Markup
constructor
A new instance of Markup.
Constructor Details
Instance Attribute Details
#links ⇒ Object (readonly)
Returns the value of attribute links.
3 4 5 |
# File 'lib/zemanta/markup.rb', line 3 def links @links end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
3 4 5 |
# File 'lib/zemanta/markup.rb', line 3 def text @text end |
Class Method Details
.fetch(text, opts = {}) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/zemanta/markup.rb', line 10 def self.fetch(text, opts = {}) relevance = opts.delete(:relevance) || 0 confidence = opts.delete(:confidence) || 0 new(suggest_markup_request(text, opts)).tap do |markup| markup.drop_links_below(relevance, confidence) end end |
Instance Method Details
#drop_links_below(relevance, confidence) ⇒ Object
19 20 21 22 23 |
# File 'lib/zemanta/markup.rb', line 19 def drop_links_below(relevance, confidence) @links.keep_if do |link| link.above?(relevance, confidence) end end |