class Object

Public Instance Methods

get(i) click to toggle source
# File bin/firstrow, line 33
def get(i); return false if $object[i].nil?;    $object[i]; end
launch_match(id, shown = 0) click to toggle source
# File bin/firstrow, line 36
def launch_match(id, shown = 0)
        match = get(id)

        if match[:links].length == 0
                puts Paint["No links found", :red]
                return
        elsif match[:links].length == 1
                link = match[:links][0]
        else
                match_input = ""
                while match_input == ""
                        
                        if shown == 0
                                print Paint["Enter stream to watch (Enter between stream 1-#{match[:links].length}): ", match[:color]]
                        else
                                print Paint["Enter another stream to watch (#{shown+1}-#{match[:links].length} or 'exit'): ", match[:color]]
                        end


                        match_input = $stdin.gets.chomp
                        
                        return false if match_input.to_i.abs == 0 or match[:links][match_input.to_i.abs - 1].nil?
                end

                link = match[:links][match_input.to_i.abs - 1]
        end

        print Paint["Opening in Google Chrome... ", "FFFFFF"]

        page_content = open(link)
        page_iframe = Nokogiri::HTML(page_content).css('iframe').first.attr('src')
        
        if not page_iframe.nil?
                open_url = page_iframe
        else
                open_url = link
        end

        if os == :windows
                `start chrome '#{page_iframe}'`
        else
                `/usr/bin/open -a "/Applications/Google Chrome.app" '#{open_url}'`
        end

        print Paint["Done. ", "FFFFFF"]
        puts

        launch_match(id, shown + 1)
end
open(url) click to toggle source
# File bin/firstrow, line 27
def open(url)
  Net::HTTP.get(URI.parse(url))
end
os() click to toggle source
# File bin/firstrow, line 9
def os
  @os ||= (
    host_os = RbConfig::CONFIG['host_os']
    case host_os
    when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
      :windows
    when /darwin|mac os/
      :macosx
    when /linux/
      :linux
    when /solaris|bsd/
      :unix
    else
      raise Error::WebDriverError, "unknown os: #{host_os.inspect}"
    end
  )
end
set(object) click to toggle source
# File bin/firstrow, line 34
def set(object); $object.push(object); $object.length - 1; end