Class: Fixnum

Inherits:
Object show all
Includes:
ValueType
Defined in:
dragon/numeric.rb

Instance Method Summary collapse

Instance Method Details

#*(other) ⇒ Object


614
615
616
617
618
619
# File 'dragon/numeric.rb', line 614

def * other
  return nil unless other
  super
rescue Exception => e
  __raise_arithmetic_exception__ other, :*, e
end

#+(other) ⇒ Object


607
608
609
610
611
612
# File 'dragon/numeric.rb', line 607

def + other
  return nil unless other
  super
rescue Exception => e
  __raise_arithmetic_exception__ other, :+, e
end

#-(other) ⇒ Object


628
629
630
631
632
633
# File 'dragon/numeric.rb', line 628

def - other
  return nil unless other
  super
rescue Exception => e
  __raise_arithmetic_exception__ other, :-, e
end

#/(other) ⇒ Object


621
622
623
624
625
626
# File 'dragon/numeric.rb', line 621

def / other
  return nil unless other
  super
rescue Exception => e
  __raise_arithmetic_exception__ other, :/, e
end

#==(other) ⇒ Object


635
636
637
638
639
# File 'dragon/numeric.rb', line 635

def == other
  return true if __original_eq_eq__ other
  return __original_eq_eq__ other.entity_id if other.is_a? GTK::OpenEntity
  return false
end

#__original_add__Object


588
# File 'dragon/numeric.rb', line 588

alias_method :__original_add__,      :+

#__original_divide__Object


591
# File 'dragon/numeric.rb', line 591

alias_method :__original_divide__,   :-

#__original_eq_eq__Object


587
# File 'dragon/numeric.rb', line 587

alias_method :__original_eq_eq__,    :==

#__original_multiply__Object


590
# File 'dragon/numeric.rb', line 590

alias_method :__original_multiply__, :*

#__original_subtract__Object


589
# File 'dragon/numeric.rb', line 589

alias_method :__original_subtract__, :-

#cosObject

Returns the cosine of a represented in degrees (NOT radians).


668
669
670
# File 'dragon/numeric.rb', line 668

def cos
  Math.cos(self.to_radians)
end

#even?Boolean

Returns `true` if the numeric value is evenly divisible by 2.

Returns:

  • (Boolean)

596
597
598
# File 'dragon/numeric.rb', line 596

def even?
  return (self % 2) == 0
end

#ifloor(int) ⇒ Object


683
684
685
# File 'dragon/numeric.rb', line 683

def ifloor int
  (self.idiv int.to_i) * int.to_i
end

#neg?Boolean

Returns `true` if number is less than `0`.

Returns:

  • (Boolean)

661
662
663
# File 'dragon/numeric.rb', line 661

def neg?
  sign < 0
end

#odd?Boolean

Returns `true` if the numeric value is NOT evenly divisible by 2.

Returns:

  • (Boolean)

603
604
605
# File 'dragon/numeric.rb', line 603

def odd?
  return !even?
end

#pos?Boolean

Returns `true` if number is greater than `0`.

Returns:

  • (Boolean)

654
655
656
# File 'dragon/numeric.rb', line 654

def pos?
  sign > 0
end

#signObject

Returns `-1` if the number is less than `0`. `+1` if the number is greater than `0`. Returns `0` if the number is equal to `0`.


645
646
647
648
649
# File 'dragon/numeric.rb', line 645

def sign
  return -1 if self < 0
  return  1 if self > 0
  return  0
end

#sinObject

Returns the cosine of a represented in degrees (NOT radians).


675
676
677
# File 'dragon/numeric.rb', line 675

def sin
  Math.sin(self.to_radians)
end

#to_sfObject


679
680
681
# File 'dragon/numeric.rb', line 679

def to_sf
  "%.2f" % self
end