Class: Miti::CLI
- Inherits:
-
Thor
- Object
- Thor
- Miti::CLI
- Defined in:
- lib/cli.rb
Overview
class to integrate CLI
Instance Method Summary collapse
-
#initialize(*args) ⇒ CLI
constructor
A new instance of CLI.
- #to_ad(nepali_date) ⇒ Object
- #to_bs(english_date) ⇒ Object
- #today ⇒ Object
Constructor Details
#initialize(*args) ⇒ CLI
Returns a new instance of CLI.
10 11 12 13 14 |
# File 'lib/cli.rb', line 10 def initialize(*args) super @shell = Thor::Shell::Color.new @output_color = :green end |
Instance Method Details
#to_ad(nepali_date) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/cli.rb', line 56 def to_ad(nepali_date) converted_english_date = Miti.to_ad(nepali_date) output_txt = "[#{converted_english_date} AD] #{converted_english_date.strftime("%B %d, %Y %A")}" rescue ConversionUnavailableError => e output_txt = e @output_color = :red ensure @shell.say(output_txt, @output_color) end |
#to_bs(english_date) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/cli.rb', line 36 def to_bs(english_date) converted_nepali_miti = Miti.to_bs(english_date) output_txt = "[#{converted_nepali_miti} BS] #{converted_nepali_miti.descriptive}" rescue ConversionUnavailableError => e output_txt = e @output_color = :red ensure @shell.say(output_txt, @output_color) end |
#today ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/cli.rb', line 17 def today date = Date.today current_nepali_miti = Miti.to_bs(date.to_s) formatted_miti = "[#{current_nepali_miti} BS] #{current_nepali_miti.descriptive}" formatted_date = "[#{date} AD] " + date.strftime("%B %d, %Y %A") @shell.say("#{formatted_miti}\n#{formatted_date}", :green) end |