Module: Flt::Support

Included in:
Num
Defined in:
lib/flt/support.rb

Defined Under Namespace

Modules: AuxiliarFunctions Classes: FlagValues, Flags, Formatter, Reader

Instance Method Summary (collapse)

Instance Method Details

- (Object) Flags(*params)

Constructor for Flags



330
331
332
333
334
335
336
# File 'lib/flt/support.rb', line 330

def Flags(*params)
  if params.size==1 && params.first.kind_of?(Flags)
    params.first
  else
    Flags.new(*params)
  end
end

- (Object) FlagValues(*params)

Constructor for FlagValues



321
322
323
324
325
326
327
# File 'lib/flt/support.rb', line 321

def FlagValues(*params)
  if params.size==1 && params.first.kind_of?(FlagValues)
    params.first
  else
    FlagValues.new(*params)
  end
end

- (Object) simplified_round_mode(round_mode, negative)

replace :ceiling and :floor rounding modes by :up/:down (depending on sign of the number to be rounded)



340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/flt/support.rb', line 340

def simplified_round_mode(round_mode, negative)
  if negative
    if round_mode == :ceiling
      round_mode = :floor
    elsif round_mode == :floor
      round_mode = :ceiling
    end
  end
  if round_mode == :ceiling
    round_mode = :up
  elsif round_mode == :floor
    round_mode = :down
  end
  round_mode
end