Class: BV::Angle

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, model = :rad) ⇒ Angle

Returns a new instance of Angle.



95
96
97
98
# File 'lib/bivector.rb', line 95

def initialize(value, model = :rad)
  @value = value
  @model = model
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



93
94
95
# File 'lib/bivector.rb', line 93

def value
  @value
end

Instance Method Details

#ang_valueObject



115
116
117
# File 'lib/bivector.rb', line 115

def ang_value
  model == :ang ? value : value * 180 / Math::PI
end

#rad_valueObject



111
112
113
# File 'lib/bivector.rb', line 111

def rad_value
  model == :rad ? value : value * Math::PI / 180
end

#switch_modelObject



104
105
106
107
108
109
# File 'lib/bivector.rb', line 104

def switch_model
  case model
  when :ang then rad_value
  when :rad then ang_value
  end 
end

#tanObject



123
124
125
# File 'lib/bivector.rb', line 123

def tan
  Math.tan(self.rad_value)
end

#to_sObject



100
101
102
# File 'lib/bivector.rb', line 100

def to_s
  value
end

#values_in(style = :rad) ⇒ Object



119
120
121
# File 'lib/bivector.rb', line 119

def values_in(style = :rad)
  style == model ? value : switch_model
end