class Sheet::Open
Attributes
name[RW]
Public Class Methods
new(name)
click to toggle source
# File lib/sheet/open.rb, line 5 def initialize(name) @name = name end
Public Instance Methods
open()
click to toggle source
# File lib/sheet/open.rb, line 9 def open if Sheet.sheet_exists?(name) process_sheet_content else Sheet.display "A cheat named #{name} doesn't exist.\nYou can create one with sheet new #{name}" end end
Private Instance Methods
process_sheet_content()
click to toggle source
# File lib/sheet/open.rb, line 18 def process_sheet_content if !sheet_urls.empty? && cmd = Sheet.open_command sheet_urls.each do |url| Sheet.exec "#{cmd} #{url.chomp.sub(/url: /,'')}" end else Sheet.display sheet_content end end
sheet_content()
click to toggle source
# File lib/sheet/open.rb, line 28 def sheet_content @sheet_content ||= File.read(Sheet.sheet_path(name)) end
sheet_urls()
click to toggle source
# File lib/sheet/open.rb, line 32 def sheet_urls @sheet_urls ||= sheet_content.split("\n").reject {|line| line !~ /^url:/ } end