Module: AstroChart
- Defined in:
- lib/astro_chart.rb,
lib/astro_chart/pure.rb,
lib/astro_chart/chart.rb,
lib/astro_chart/houses.rb,
lib/astro_chart/zodiac.rb,
lib/astro_chart/aspects.rb,
lib/astro_chart/planets.rb,
lib/astro_chart/version.rb,
lib/astro_chart/synastry.rb,
lib/astro_chart/ephemeris.rb,
lib/astro_chart/pure/core.rb,
lib/astro_chart/pure/moon.rb,
lib/astro_chart/pure/pluto.rb,
lib/astro_chart/pure/houses.rb,
lib/astro_chart/pure/vsop87.rb,
lib/astro_chart/pure/moon_elp.rb,
lib/astro_chart/time_conversion.rb,
lib/astro_chart/pure/vsop87_data.rb
Defined Under Namespace
Modules: Aspects, Ephemeris, Houses, Planets, Pure, Synastry, TimeConversion, Zodiac Classes: Chart
Constant Summary collapse
- VERSION =
"0.2.0"- DEFAULT_BACKEND =
:pure
Class Method Summary collapse
-
.backend ⇒ Object
Current ephemeris backend (:pure or :swiss).
-
.backend=(name) ⇒ Object
Switch the ephemeris backend.
- .load_swiss_extension! ⇒ Object
Class Method Details
.backend ⇒ Object
Current ephemeris backend (:pure or :swiss). Defaults to :pure.
8 9 10 |
# File 'lib/astro_chart/ephemeris.rb', line 8 def backend @backend ||= DEFAULT_BACKEND end |
.backend=(name) ⇒ Object
Switch the ephemeris backend.
AstroChart.backend = :pure # pure-Ruby (default, no C extension needed)
AstroChart.backend = :swiss # Swiss Ephemeris C extension (AGPL)
Selecting :swiss loads the C extension on demand; a missing/uncompiled extension raises LoadError with an explicit message instead of failing silently at call time.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/astro_chart/ephemeris.rb', line 20 def backend=(name) case name when :pure @backend = :pure when :swiss load_swiss_extension! @backend = :swiss else raise ArgumentError, "unknown backend #{name.inspect} (expected :pure or :swiss)" end end |
.load_swiss_extension! ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/astro_chart/ephemeris.rb', line 33 def load_swiss_extension! return if defined?(AstroChart::Ext) begin require_relative "astro_chart_ext" rescue LoadError => e raise LoadError, "AstroChart :swiss backend requires the compiled Swiss Ephemeris C extension " \ "(astro_chart_ext). Build it with `rake compile` (or `ruby ext/astro_chart/extconf.rb && make`), " \ "or use the default pure-Ruby backend (AstroChart.backend = :pure). " \ "Original error: #{e.}" end end |