Module: Utils
- Defined in:
- lib/utils.rb
Class Method Summary collapse
- .display_by_reader(content) ⇒ Object
- .html_to_text(html_text) ⇒ Object
- .open_url(url) ⇒ Object
- .url_text(text, url) ⇒ Object
Class Method Details
.display_by_reader(content) ⇒ Object
13 14 15 |
# File 'lib/utils.rb', line 13 def self.display_by_reader(content) system("echo '#{content}' | less") end |
.html_to_text(html_text) ⇒ Object
9 10 11 |
# File 'lib/utils.rb', line 9 def self.html_to_text(html_text) Nokogiri::HTML(html_text).text end |
.open_url(url) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/utils.rb', line 17 def self.open_url(url) cmd = case RbConfig::CONFIG['host_os'] when /mswin|mingw|cygwin/ then 'start ' when /darwin/ then 'open ' when /linux|bsd/ then 'xdg-open ' else raise 'No OS detected' end system cmd + url end |
.url_text(text, url) ⇒ Object
5 6 7 |
# File 'lib/utils.rb', line 5 def self.url_text(text, url) TTY::Link.link_to(text, url) end |