Class: GHI::Web

Inherits:
Object
  • Object
show all
Defined in:
lib/ghi/web.rb

Constant Summary collapse

HOST =
GHI.config('github.host') || 'github.com'
BASE_URI =
"https://#{HOST}/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base) ⇒ Web

Returns a new instance of Web.



10
11
12
# File 'lib/ghi/web.rb', line 10

def initialize base
  @base = base
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



9
10
11
# File 'lib/ghi/web.rb', line 9

def base
  @base
end

Instance Method Details

#curl(path = '', params = {}) ⇒ Object



23
24
25
# File 'lib/ghi/web.rb', line 23

def curl path = '', params = {}
  uri_for(path, params).open.read
end

#open(path = '', params = {}) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/ghi/web.rb', line 14

def open path = '', params = {}
  path = uri_for path, params
  $stdout.puts path
  return unless $stdout.tty?
  launcher = 'open'
  launcher = 'xdg-open' if /linux/ =~ RUBY_PLATFORM
  system "#{launcher} '#{path}'"
end