class Snippet

Attributes

contents[RW]
fragments[RW]

Public Class Methods

new(file) click to toggle source
# File lib/bunch/url_generator.rb, line 130
def initialize(file)
  if File.exist?(File.expand_path(file))
    @contents = IO.read(File.expand_path(file))
    @fragments = fragments
  else
    throw ('Tried to initialize snippet with invalid file')
  end
end

Public Instance Methods

choose_fragment() click to toggle source
# File lib/bunch/url_generator.rb, line 152
def choose_fragment
  unless @fragments.empty?
    items = []
    @fragments.each { |k, v| items << MenuItem.new(k, k, v) }
    menu = Menu.new(items)
    return menu.choose('Select fragment')
  end
  nil
end