Class: Modown::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/modown.rb

Overview

The CLI is a class responsible of handling all the command line interface logic.

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



12
13
14
# File 'lib/modown.rb', line 12

def initialize
  @options = {}
end

Instance Method Details

#get_models(name, count = 1, format = '*.3[Dd][Ss]') ⇒ void

This method returns an undefined value.

This method integrates the Modown.download_model , Modown.search_models and Modown.get_model_from_zip methods

Parameters:

  • name (String)

    the name of the thing you want to download 3D models.example “cat”,“bottle”,etc

  • count (Integer) (defaults to: 1)

    the number of models you want

  • format (String) (defaults to: '*.3[Dd][Ss]')

    the glob pattern of the desired 3D model file format



29
30
31
32
33
34
# File 'lib/modown.rb', line 29

def get_models(name, count = 1, format = '*.3[Dd][Ss]')
  Modown::search_models(name, count).each do |id|
    Modown::download_model(id)
    Modown::get_model_from_zip(id + '.zip', name + '_' + id, format)
  end
end

#run(args = ARGV) ⇒ Object

This method is the entry point for the command-line app



17
18
19
20
21
# File 'lib/modown.rb', line 17

def run(args = ARGV)
  @options = Options.new.parse(args)

  get_models(@options[:search_term], @options[:count], @options[:format])
end