Class: Gistgen::CrunchView
- Inherits:
-
Object
- Object
- Gistgen::CrunchView
- Defined in:
- lib/gistgen/crunch_view.rb
Instance Method Summary collapse
- #homepage ⇒ Object
-
#initialize(name) ⇒ CrunchView
constructor
A new instance of CrunchView.
- #overview(length = 500) ⇒ Object
- #permalink ⇒ Object
Constructor Details
#initialize(name) ⇒ CrunchView
Returns a new instance of CrunchView.
10 11 12 13 14 15 16 17 18 |
# File 'lib/gistgen/crunch_view.rb', line 10 def initialize(name) begin res = Gistgen::Page.get_page("http://api.crunchbase.com/v/1/company/#{name}.js") @json = JSON.parse(res) @json = (@json and @json['overview'])? @json : nil rescue nil end end |
Instance Method Details
#homepage ⇒ Object
38 39 40 |
# File 'lib/gistgen/crunch_view.rb', line 38 def homepage (@json)? Gistgen::URL.standardize(@json['homepage_url']) : nil end |
#overview(length = 500) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/gistgen/crunch_view.rb', line 20 def overview(length=500) begin text = @json['overview'].gsub(/\u003C(.*?)\\u003E/,'').gsub(/<(.*?)>/,'').gsub("\n",'') text = HTMLEntities.new.decode(text) #decode_html text.extract_passage(0, length) rescue nil end end |
#permalink ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/gistgen/crunch_view.rb', line 30 def permalink begin Gistgen::URL.standardize("http://www.crunchbase.com/company/#{@json['permalink']}") rescue nil end end |