Sha256: d067e0fd9cdabe796b2fc436df0ed03c226514818df5ee59ec0d409a303d9fa3

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require 'yaml'
require 'extensions'
require 'alumina/errors'
require 'alumina/hin/writer'
require 'alumina/element'
require 'alumina/atom'
require 'alumina/molecule'
require 'alumina/hin'
require 'alumina/hin/parser'

# Container module for classes of the Alumina gem.

module Alumina
  # @private
  ELEMENTS_PATH = File.expand_path("#{File.dirname(__FILE__)}/../data/elements.yml")
  # An array of all {Element Elements}, loaded from a YAML data file.
  ELEMENTS = YAML.load(File.read(ELEMENTS_PATH)).map { |atomic_number, data| Element.new(atomic_number, data[:name], data[:symbol]) }
  # All elements hashed by their symbol (e.g., "Ag" for silver).
  ELEMENTS_BY_SYMBOL = ELEMENTS.inject({}) { |hsh, cur| hsh[cur.symbol] = cur ; hsh }
  # All elements hashed by their atomic number.
  ELEMENTS_BY_NUMBER = ELEMENTS.inject({}) { |hsh, cur| hsh[cur.atomic_number] = cur ; hsh }
  
  # Creates a {HIN::Parser} and calls {HIN::Parser#parse} on it.
  #
  # @param [IO, String] input The HIN data to parse.
  # @return [Array<Alumina::Molecule>] The molecules described by the data.
  # @raise [ParseError] If the HIN data is improperly formatted.
  
  def self.HIN(input)
    Alumina::HIN::Parser.new.parse(input)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alumina-0.0.1 lib/alumina.rb