Class: Ffnpdf::Exec
- Inherits:
-
Object
- Object
- Ffnpdf::Exec
- Defined in:
- lib/ffnpdf/exec.rb
Instance Method Summary collapse
-
#initialize(argv) ⇒ Exec
constructor
A new instance of Exec.
Constructor Details
#initialize(argv) ⇒ Exec
Returns a new instance of Exec.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ffnpdf/exec.rb', line 3 def initialize(argv) invalid = false if argv.size == 0 invalid = true elsif /^[\d]+$/.match argv[0] story = Ffnpdf::Story.new(argv[0]) if story.check_story story.pull_story story.build_story else $stderr.puts story.error end elsif argv[0] == "pull" and /^[\d]+$/.match argv[1] story = Ffnpdf::Story.new(argv[1]) if story.check_story story.pull_story else $stderr.puts story.error end elsif argv[0] == "build" and /^[\d]+$/.match argv[1] story = Ffnpdf::Story.new(argv[1]) if story.check_story_dir story.build_story else $stderr.puts story.error end elsif argv[0] == "convert" and /^[\d]+$/.match argv[1] story = Ffnpdf::Story.new(argv[1]) if story.check_story_dir story.convert_to_pdf else $stderr.puts story.error end else invalid = true end if invalid $stderr.puts <<-MSG Usage ffnpdf [STORY_ID] ffnpdf [COMMAND] [STORY_ID] Description Scrapes story from FanFiction.net and generates pdf at STORY_ID/ folder. The following commands are available pull scrapes story and puts the markdown and template files at STORY_ID/ folder build compiles *.md files at STORY_ID/ into a single pdf convert converts STORY_ID/combined.md to pdf using the template files MSG end end |