Module: BibTeX::Options::SortOptions

Defined in:
lib/rbibtex/transform.rb

Overview

Module to be included into an OptionParser parser. Creates sort by switch.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sort_byObject (readonly)

Returns the value of attribute sort_by.



30
31
32
# File 'lib/rbibtex/transform.rb', line 30

def sort_by
  @sort_by
end

Instance Method Details

#initializeObject



32
33
34
35
36
37
38
39
# File 'lib/rbibtex/transform.rb', line 32

def initialize
	super()

	self.separator ""
	self.separator "Sorting of entries"
	self.on("-s", "--sort-by", "--sort_by Field_1,Field2,...", Array,
		"Specify fields that shall be used for sorting of the file")       { | v | @sort_by  = v.map { | e | e.downcase.to_sym  } }
end

#parse!(*args) ⇒ Object



41
42
43
44
# File 'lib/rbibtex/transform.rb', line 41

def parse!(*args)      
	super
	raise "You can't specify an empty list of fields for sorting" if @sort_by and @sort_by.empty?
end