Class: SmTranscript::Options
- Inherits:
-
Object
- Object
- SmTranscript::Options
- Defined in:
- lib/sm_transcript/options.rb
Constant Summary collapse
- SEG_SRC_TYPE =
'seg'
- WRD_SRC_TYPE =
'wrd'
- TXT_SRC_TYPE =
'txt'
- TTML_DEST_TYPE =
'ttml'
- HTML_DEST_TYPE =
'html'
- DATAJS_DEST_TYPE =
'datajs'
- DEFAULT_SRC_DIR =
"./results"
- DEFAULT_DEST_DIR =
"./transcripts"
- DEFAULT_SRC_TYPE =
WRD_SRC_TYPE
- DEFAULT_DEST_TYPE =
HTML_DEST_TYPE
Instance Attribute Summary collapse
-
#destdir ⇒ Object
readonly
Returns the value of attribute destdir.
-
#desttype ⇒ Object
readonly
Returns the value of attribute desttype.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#srcdir ⇒ Object
readonly
Returns the value of attribute srcdir.
-
#srctype ⇒ Object
readonly
Returns the value of attribute srctype.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Options
constructor
A new instance of Options.
- #parse(argv) ⇒ Object
Constructor Details
#initialize(argv) ⇒ Options
Returns a new instance of Options.
28 29 30 31 32 33 34 35 |
# File 'lib/sm_transcript/options.rb', line 28 def initialize(argv) @options = OpenStruct.new @srcdir = DEFAULT_SRC_DIR @destdir = DEFAULT_DEST_DIR @srctype = DEFAULT_SRC_TYPE @desttype = DEFAULT_DEST_TYPE parse(argv) end |
Instance Attribute Details
#destdir ⇒ Object (readonly)
Returns the value of attribute destdir.
23 24 25 |
# File 'lib/sm_transcript/options.rb', line 23 def destdir @destdir end |
#desttype ⇒ Object (readonly)
Returns the value of attribute desttype.
25 26 27 |
# File 'lib/sm_transcript/options.rb', line 25 def desttype @desttype end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
26 27 28 |
# File 'lib/sm_transcript/options.rb', line 26 def @options end |
#srcdir ⇒ Object (readonly)
Returns the value of attribute srcdir.
22 23 24 |
# File 'lib/sm_transcript/options.rb', line 22 def srcdir @srcdir end |
#srctype ⇒ Object (readonly)
Returns the value of attribute srctype.
24 25 26 |
# File 'lib/sm_transcript/options.rb', line 24 def srctype @srctype end |
Instance Method Details
#parse(argv) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/sm_transcript/options.rb', line 37 def parse(argv) @options.srcdir = @srcdir @options.destdir = @destdir @options.srctype = @srctype @options.desttype = @desttype opts = OptionParser.new do |opts| opts. = "Usage: sm_transcript [options]" opts.separator " " opts.separator "Specific options:" opts.on( "--srcdir PATH", "Read files from this folder (Default: ./results)") do |sdir| @options.srcdir = @srcdir = sdir end opts.on( "--destdir PATH", String, "Write files to this folder (Default: ./transcripts)") do |ddir| @options.destdir = @destdir = ddir end opts.on("--srctype seg | wrd | txt", "Kind of file to process (Default: seg)") do |stype| @options.srctype = @srctype = stype end opts.on("--desttype html | ttml | datajs", "Kind of format to output (Default: html)") do |dtype| @options.desttype = @desttype = dtype end opts.on("-h", "--help", "Show this message") do puts "\n#{opts}" return end begin argv = ["-h"] if argv.empty? opts.parse!(argv) rescue OptionParser::ParseError => e STDERR.puts e., "\n", opts exit(-1) end end end |