Class: ScriptRipper::CLI
- Inherits:
-
Object
- Object
- ScriptRipper::CLI
- Includes:
- Util
- Defined in:
- lib/script_ripper/cli.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#group_name ⇒ Object
readonly
Returns the value of attribute group_name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
- #group_by ⇒ Object
-
#initialize(arguments = ARGV) ⇒ CLI
constructor
A new instance of CLI.
Methods included from Util
Constructor Details
#initialize(arguments = ARGV) ⇒ CLI
Returns a new instance of CLI.
14 15 16 17 |
# File 'lib/script_ripper/cli.rb', line 14 def initialize(arguments = ARGV) @arguments = arguments @options = {} end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
12 13 14 |
# File 'lib/script_ripper/cli.rb', line 12 def arguments @arguments end |
#group_name ⇒ Object (readonly)
Returns the value of attribute group_name.
12 13 14 |
# File 'lib/script_ripper/cli.rb', line 12 def group_name @group_name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/script_ripper/cli.rb', line 12 def @options end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
12 13 14 |
# File 'lib/script_ripper/cli.rb', line 12 def url @url end |
Class Method Details
.call(arguments = ARGV) ⇒ Object
33 34 35 |
# File 'lib/script_ripper/cli.rb', line 33 def call(arguments = ARGV) new(arguments).call end |
Instance Method Details
#call ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/script_ripper/cli.rb', line 19 def call parse_arguments! content = Downloader.call(url) code_blocks = Parser.call(content, group_by) if code_blocks.is_a?(Hash) ScriptWriter.call(code_blocks: code_blocks.fetch(group_name), from_url: url, group_name: group_name) else ScriptWriter.call(code_blocks: code_blocks, from_url: url) end end |
#group_by ⇒ Object
38 39 40 |
# File 'lib/script_ripper/cli.rb', line 38 def group_by [:"group-by"] end |