Class: Homebrew::Formula::Description

Inherits:
Object
  • Object
show all
Defined in:
app/models/homebrew/formula/description.rb

Overview

Extract the Homebrew::Formula description from its homepage

Author:

  • guillaumeh

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(formula) ⇒ Homebrew::Formula::Description

Instanciate a new Homebrew::Formula::Description

Parameters:

  • formula (Homebrew::Formula)

    Formula for which the description has to be extracted


18
19
20
21
# File 'app/models/homebrew/formula/description.rb', line 18

def initialize(formula)
  @formula = formula
  @text = nil
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text


9
10
11
# File 'app/models/homebrew/formula/description.rb', line 9

def text
  @text
end

Instance Method Details

#found?Boolean

Determine if a description has been found

Returns:

  • (Boolean)

    true if a description has been found otherwise false


36
37
38
# File 'app/models/homebrew/formula/description.rb', line 36

def found?
  @text.present?
end

#lookup_from(content) ⇒ Object

Look up for a description in the given string

Parameters:

  • content (String)

    String containing somewhere the description


27
28
29
30
# File 'app/models/homebrew/formula/description.rb', line 27

def lookup_from(content)
  @html = Nokogiri::HTML(content)
  grab_description
end