Module: JottitTo
- Defined in:
- lib/jottit-to.rb,
lib/jottit/version.rb
Defined Under Namespace
Modules: ArrayExtender Classes: CLI
Constant Summary collapse
- VERSION =
"0.1.1"
Class Method Summary collapse
Class Method Details
.normalize_uri(src) ⇒ Object
e.g. youpy.jottit.com/trivia?m=diff&r=525&r=526#fuba =>
http://youpy.jottit.com/trivia
46 47 48 49 50 51 |
# File 'lib/jottit-to.rb', line 46 def normalize_uri(src) uri = URI(src) uri.query = nil uri.fragment = nil uri.to_s end |
.parse_html(html) ⇒ Object
e.g. <div id=“content”><ul><li>foo</li><li>bar</li><ul></div> =>
['foo', 'bar']
55 56 57 58 59 60 |
# File 'lib/jottit-to.rb', line 55 def parse_html(html) html = Nokogiri::HTML(html) items = html.css('#content>ul>li').map(&:text) items.extend JottitTo::ArrayExtender items end |
.parse_uri(uri) ⇒ Object
e.g. youpy.jottit.com/trivia => [‘foo’, ‘bar’]
63 64 65 66 |
# File 'lib/jottit-to.rb', line 63 def parse_uri(uri) html = URI(normalize_uri(uri)).read parse_html(html) end |