Class: Astroscript::Midpoint

Inherits:
Body
  • Object
show all
Defined in:
lib/astroscript/body/midpoint.rb

Constant Summary

Constants inherited from Body

Body::ANGLES, Body::AVG_VELOCITY, Body::MAX_VELOCITY, Body::ORBS, Body::SPEED_ORDER, Body::STATIONARY_VELOCITY

Instance Attribute Summary collapse

Attributes inherited from Body

#altitude, #antipode, #azimuth, #calc, #decl, #distance, #harmonic, #hdist, #hlat, #hlon, #hvel, #lat, #ra, #velocity

Instance Method Summary collapse

Methods inherited from Body

#*, #==, #closer_to_sun?, #decan, #distance_to_sun, #duad, #dwad, #element, #element_sym, #feminine?, #flip, #flip!, #gate, #handle, #harmonic_sign, #harmonic_signs, #harmonize, #harmonize!, #house, #in_detriment?, #in_domicile?, #in_exaltation?, #in_fall?, #inner?, #is_angle?, #lon, #luminary?, #masculine?, #meridian_degree, #midpoint?, #modality, #name, #navamsha, #outer?, #pentan, #personal_angle?, phase, #prefix, #prime_degree, #print, #radix, #relative_velocity, #retrograde?, #ruler, #sign, #sign_and_house, #sign_i, #sign_sym, #speed_order, #stationary?, #subduad, #subdwad, #subpentan, #to_dms, #to_json, #to_s, #transit!, #transit?, #triple_harmonic_signs, #yang?, #yin?

Constructor Details

#initialize(b1, b2, opts = {}) ⇒ Midpoint

Returns a new instance of Midpoint.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/astroscript/body/midpoint.rb', line 7

def initialize(b1, b2, opts = {})
  @harmonic = opts[:harmonic] || 1
  @bodies = [b1, b2]
  @name = abbr.sub(operator, "_")
  @symbol = @bodies.map(&:symbol).join(operator)
  @lon = @bodies.map(&:lon).avg
  if ((@lon - b1.lon).abs % 360) > 90
    @lon = (@lon + 180) % 360 # flip!
  end
  update!
end

Instance Attribute Details

#bodiesObject (readonly)

Returns the value of attribute bodies.



5
6
7
# File 'lib/astroscript/body/midpoint.rb', line 5

def bodies
  @bodies
end

Instance Method Details

#abbrObject



23
24
25
# File 'lib/astroscript/body/midpoint.rb', line 23

def abbr
  bodies.map(&:abbr).join(operator)
end

#calculate!Object



19
20
21
# File 'lib/astroscript/body/midpoint.rb', line 19

def calculate!
  bodies.each(&:calculate!)
end

#inspectObject



35
36
37
38
39
# File 'lib/astroscript/body/midpoint.rb', line 35

def inspect
  return super unless defined?(IRB)

  "#{bodies.first.abbr}/#{bodies.last.abbr}\t#{AstroHelper.deg_to_s(lon)}"
end

#symbolObject



27
28
29
# File 'lib/astroscript/body/midpoint.rb', line 27

def symbol
  bodies.map(&:symbol).join(operator)
end

#to_symObject



31
32
33
# File 'lib/astroscript/body/midpoint.rb', line 31

def to_sym
  abbr.to_sym
end