Class: EphJpl::Argument
- Inherits:
-
Object
- Object
- EphJpl::Argument
- Defined in:
- lib/eph_jpl/argument.rb
Instance Method Summary collapse
- #check_bin_path(bin_path) ⇒ Object
- #check_target_center(target, center) ⇒ Object
-
#get_args ⇒ Object
引数取得.
- #get_binpath ⇒ Object
- #get_center ⇒ Object
- #get_jd ⇒ Object
- #get_km ⇒ Object
- #get_target ⇒ Object
-
#initialize(*args) ⇒ Argument
constructor
A new instance of Argument.
Constructor Details
#initialize(*args) ⇒ Argument
Returns a new instance of Argument.
3 4 5 |
# File 'lib/eph_jpl/argument.rb', line 3 def initialize(*args) @args = *args end |
Instance Method Details
#check_bin_path(bin_path) ⇒ Object
82 83 84 |
# File 'lib/eph_jpl/argument.rb', line 82 def check_bin_path(bin_path) raise Const::MSG_ERR_2 unless File.exist?(bin_path) end |
#check_target_center(target, center) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/eph_jpl/argument.rb', line 72 def check_target_center(target, center) case when target == center raise Const::MSG_ERR_5 when target < 14 && center == 0, target > 13 && center != 0 raise Const::MSG_ERR_6 end end |
#get_args ⇒ Object
引数取得
@return: [BIN_PATH, TARGET, CENTER, JD, KM]
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/eph_jpl/argument.rb', line 12 def get_args bin_path = get_binpath target = get_target center = get_center jd = get_jd km = get_km check_bin_path(bin_path) check_target_center(target, center) return [bin_path, target, center, jd, km] rescue => e raise end |
#get_binpath ⇒ Object
25 26 27 28 29 30 |
# File 'lib/eph_jpl/argument.rb', line 25 def get_binpath raise unless bin_path = @args.shift return bin_path rescue => e raise Const::MSG_ERR_1 end |
#get_center ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/eph_jpl/argument.rb', line 41 def get_center raise unless center = @args.shift raise unless center.to_s =~ /^\d+$/ raise if center.to_i < 0 || 13 < center.to_i return center.to_i rescue => e raise Const::MSG_ERR_4 end |
#get_jd ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/eph_jpl/argument.rb', line 50 def get_jd raise unless jd = @args.shift if jd.to_s !~ /^[\d\.]+$/ || \ jd.to_f < Const::EPOCH_PERIOD[0] || \ Const::EPOCH_PERIOD[1] < jd.to_f raise end return jd.to_f rescue => e raise Const::MSG_ERR_7 end |