eulim 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9458ac12cd3f10344612c1f8cad1fc3639b1d878
4
- data.tar.gz: 79136853fc2477a505708f4d0bac0e4e40b4508d
3
+ metadata.gz: 7a4ff2d9a51f17fe9a667eb929f4b4d40b17089a
4
+ data.tar.gz: b99d998f6b941096cc7f5dbd0fe5cc66ac3e6140
5
5
  SHA512:
6
- metadata.gz: 374cecc8f1569af9bde3f669b723318bd20c77f0cf02d799f41e7d53d7389423b3d6423aa8cceb49ef06d2214f9eed4defff0365ef796497b7d109f3bf1392dd
7
- data.tar.gz: c3056b7cb8130ac6e7edf2128e0348de82c84cf59afb821782030eb1a0148789fd392ba0ff6588057e13864ac9af49a040af303c70d644f911c26bffd0737675
6
+ metadata.gz: 3e6d1107d1d3f100b2a5202e36b8121417d01294e6c58e64cfa7473acbb04218e880bb4728dede64569a25ff6dd4fa252f40fef46cfbb5b92f6d265c40207780
7
+ data.tar.gz: a89714402c6448c539fd954a9b34f1931beb92aa9060cef227b4c4203ea5a1a9a69924ec8ef7b7898ea316adb3a95b16469660434ae161171455dbec6b8ab6da
data/eulim.gemspec CHANGED
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'eulim/version'
@@ -6,9 +7,8 @@ require 'eulim/version'
6
7
  Gem::Specification.new do |spec|
7
8
  spec.name = 'eulim'
8
9
  spec.version = Eulim::VERSION
9
- spec.authors = ['Syed Fazil Basheer','Somesh Choudhary']
10
+ spec.authors = ['Syed Fazil Basheer', 'Somesh Choudhary']
10
11
  spec.email = ['fazil.basheer@quester.xyz', 'c.somesh5@gmail.com']
11
-
12
12
 
13
13
  spec.summary = 'A gem for scientific data.'
14
14
  spec.description = 'A gem for scientific data.'
@@ -8,19 +8,36 @@ module Eulim
8
8
  def initialize(args = {})
9
9
  @volume = volume_if_valid(args[:volume]) if args[:volume]
10
10
  @system = args[:system] || :open
11
+ @input = input_if_valid(args[:input]) if args[:input]
11
12
  end
12
13
 
13
14
  private
14
15
 
15
16
  def volume_if_valid(vol)
16
17
  begin
17
- vol = Unitwise(vol)
18
+ vol = Unitwise vol
18
19
  rescue
19
- raise ArgumentError, 'Invalid volume argument'
20
+ raise ArgumentError, 'Invalid volume'
20
21
  end
21
22
  return vol if vol.composition.to_h == { 'L' => 3 }
22
23
  raise ArgumentError, 'Invalid volume unit'
23
24
  end
25
+
26
+ def input_if_valid(inp)
27
+ raise ArgumentError, 'Invalid input substance' if inp[:substance].class != Subs
28
+ begin
29
+ inp[:quantity] = Unitwise inp[:quantity]
30
+ rescue
31
+ raise ArgumentError, 'Invalid input quantity'
32
+ end
33
+ dim = inp[:quantity].composition.to_h
34
+ return inp if valid_input_quantity_compositions.include? dim
35
+ raise ArgumentError, 'Invalid input quantity unit'
36
+ end
37
+
38
+ def valid_input_quantity_compositions
39
+ [{ 'M' => 1 }, { 'M' => 1, 'T' => -1 }, {}, { 'T' => -1 }]
40
+ end
24
41
  end
25
42
  end
26
43
  end
@@ -5,7 +5,11 @@ module Eulim
5
5
  class Reaction
6
6
  attr_accessor :equation, :is_valid, :is_balanced, :species
7
7
 
8
- STATES = { '(s)' => 'solid', '(l)' => 'liquid', '(g)' => 'gaseous', '(aq)' => 'aqueous', "" => 'liquid' }
8
+ STATES = {
9
+ '(s)' => 'solid', '(l)' => 'liquid',
10
+ '(g)' => 'gaseous', '(aq)' => 'aqueous',
11
+ '' => 'liquid'
12
+ }.freeze
9
13
 
10
14
  def initialize(arg)
11
15
  @equation = arg
@@ -14,7 +18,7 @@ module Eulim
14
18
  @is_balanced = balanced_rxn?
15
19
  end
16
20
 
17
- # private
21
+ private
18
22
 
19
23
  def build_species
20
24
  r = {}
@@ -34,7 +38,7 @@ module Eulim
34
38
  st = get_state specie
35
39
  offset_sc = sc.zero? ? 0 : sc.to_s.length
36
40
  offset_st = st.empty? ? 0 : st.length
37
- specie_str = specie[offset_sc..(specie.length - offset_st -1)]
41
+ specie_str = specie[offset_sc..(specie.length - offset_st - 1)]
38
42
  {
39
43
  specie_str => {
40
44
  compound: Compound.new(specie_str),
data/lib/eulim/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eulim
2
- VERSION = '0.0.12'.freeze
2
+ VERSION = '0.0.13'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eulim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Syed Fazil Basheer