Module: Mead::TrollopOptions

Defined in:
lib/mead/trollop.rb

Instance Method Summary collapse

Instance Method Details

#check_options(opts) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/mead/trollop.rb', line 3

def check_options(opts)
  number_of_get_methods = [:baseurl, :url, :file].inject(0) do |memo, option| 
    temp_memo = memo
    temp_memo += 1 if opts[option]
    temp_memo
  end
  if number_of_get_methods > 1
    Trollop::die 'Must specify ONLY one way to get the Ead XML' 
  elsif number_of_get_methods == 0
    Trollop::die 'Must specify at least one way to get the Ead XML' 
  end
end

#get_location(opts) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/mead/trollop.rb', line 28

def get_location(opts)
  if opts[:baseurl]
    opts[:baseurl]
  elsif opts[:url]
    opts[:url]
  elsif opts[:file]
    File.open(opts[:file])
  end
end

#get_location_options(opts) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mead/trollop.rb', line 16

def get_location_options(opts)
  location_options = {}
  if opts[:baseurl]
    location_options[:baseurl] = opts[:baseurl]
  elsif opts[:url]
    location_options[:url] = opts[:url]
  elsif opts[:file]
    location_options[:file] = File.open(opts[:file])
  end
  location_options
end