jievro-ast 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b635eefafea61126d46bddae9e11429e5fd53b4
4
- data.tar.gz: 692f6e8638c7fd7779a9297dd9fd257073ec85a0
3
+ metadata.gz: b3a255322b21284974bd0fd3355b312962e064fc
4
+ data.tar.gz: 41f7e711f44e2fded4df1b84451381bda69bec6c
5
5
  SHA512:
6
- metadata.gz: 64c5715f3c511da6ed9575fda78fb4b8908c8bd92f7aa360c509790a862df9a913ecc52a796baa5e3b644069c094fd883c4aaeaa69a0bb75d4ac99de100346e0
7
- data.tar.gz: 98208d05de7a6ce570fe230758af8d18cb170cbc0105ae5f579a38158bb0ca0daf70fc19bacbda881640b7b7c81ce0a5233eb7f1c1c52040dd81c4c2af34a536
6
+ metadata.gz: cea7140044cabf7eaf71ace097c966205d59b5166f10072adfa2478f22ba725e513dffdd57b440d23785f8e9011a870b064292b0cdbc48f08685a96c521e45db
7
+ data.tar.gz: 8093e28b845181559d24ad807471ef755bcc62d233cac1871f10119c1aade94bc3500bc42459610e0957cdc12a7feb79d5a4c7221be7b6388e784ebcec030d5f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jievro-ast (0.3.1)
4
+ jievro-ast (0.3.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,6 +1,9 @@
1
1
  module Jievro
2
2
  module Ast
3
3
  class Node
4
+ TYPE_LITERAL = '__literal'
5
+ TYPE_COLLECTION = '__collection'
6
+
4
7
  attr_reader :parent, :type, :value
5
8
 
6
9
  def initialize(initializer, parent = nil, key = nil)
@@ -39,7 +42,7 @@ module Jievro
39
42
 
40
43
  def value
41
44
  fail Exception, 'Cannot get value from a non literal node' \
42
- unless @type == '__literal'
45
+ unless @type == TYPE_LITERAL
43
46
 
44
47
  @value
45
48
  end
@@ -49,14 +52,14 @@ module Jievro
49
52
  end
50
53
 
51
54
  def each
52
- each_with_index do |v, i|
55
+ each_with_index do |v, _|
53
56
  yield v
54
57
  end
55
58
  end
56
59
 
57
60
  def each_with_index
58
- fail Exception, 'Cannot loop a literal node' \
59
- if @type == '__literal'
61
+ fail Exception, 'Cannot iterate a literal node' \
62
+ if @type == TYPE_LITERAL
60
63
 
61
64
  @value.keys.each do |v|
62
65
  yield @value[v], v
@@ -67,12 +70,12 @@ module Jievro
67
70
 
68
71
  def initialize_as_literal(initializer)
69
72
  @value = initializer
70
- @type = '__literal'
73
+ @type = TYPE_LITERAL
71
74
  end
72
75
 
73
76
  def initialize_as_array(initializer)
74
77
  @value = {}
75
- @type = '__collection'
78
+ @type = TYPE_COLLECTION
76
79
 
77
80
  initializer.each_with_index do |e, i|
78
81
  @value[i] = Node.new(e, self, i)
@@ -1,5 +1,5 @@
1
1
  module Jievro
2
2
  module Ast
3
- VERSION = '0.3.1'
3
+ VERSION = '0.3.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jievro-ast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Azzalini