dates_from_string 0.5.0 → 0.6.0

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: dcccdda19e565c99699a5f0d8c6fb817d638dac1
4
- data.tar.gz: ee541a880654b1303f544ddc3b8daa77a8ee18e2
3
+ metadata.gz: a7f3aad632d0a54f6bfb007d875bdca1da734c07
4
+ data.tar.gz: 9db1c2e76db53abd438ffec8824f33640e0112cf
5
5
  SHA512:
6
- metadata.gz: 4923d3dab2741a944e9850fd705e12734ce8b0a7380f54f7fa29b0cb6c701589cdeb0a450ece7c822c60eba2e4749c82df7d853888ff3fa30526e5feed4d852a
7
- data.tar.gz: 3162c55e8fe7585ba3ade3de7646ab8952774f1f34e8e0cde1b6ef39a0af612abbf4071e7642085928fbce3d1c557eb96a39b110486b88f83097078e48390a93
6
+ metadata.gz: 168000c875ef7203c827689251c722a84c96859bec290086849e05715abd3d16801e269047f05b9f4ee6460322190216c4c392c8d0716a60a510cd6ffed94353
7
+ data.tar.gz: cd4aba31a3bee5a47f2bf820521c3e5395da30ab1f7184a71a55174970e0b9fb18538db08aaa4e128e66c0b931aada0e37e76c967d71ae5c830fbd9306104bec
data/README.md CHANGED
@@ -90,11 +90,22 @@ dates_from_string.get_structure(input)
90
90
  #
91
91
 
92
92
  input = 'circa 1960 and full date 07 Jun 1941'
93
+ dates_from_string.get_structure(input)
94
+
95
+ #=> return
96
+ # [{:type=>:year, :value=>"1960", :distance=>4, :key_words=>[]},
97
+ # {:type=>:day, :value=>"07", :distance=>1, :key_words=>[]},
98
+ # {:type=>:month, :value=>"06", :distance=>1, :key_words=>[]},
99
+ # {:type=>:year, :value=>"1941", :distance=>0, :key_words=>[]}]
100
+
101
+ obj = DatesFromString.new(['and'])
102
+ input = 'between 1960 and 1965'
103
+ obj.get_structure(input)
104
+
93
105
  #=> return
94
- #[{:type=>:year, :value=>"1960", :distance=>5, :key_words=>[]},
95
- #{:type=>:day, :value=>"07", :distance=>1, :key_words=>[]},
96
- #{:type=>:month, :value=>"06", :distance=>1, :key_words=>[]},
97
- #{:type=>:year, :value=>"1941", :distance=>0, :key_words=>[]}]
106
+ # [{:type=>:year, :value=>"1960", :distance=>2, :key_words=>['and']},
107
+ # {:type=>:year, :value=>"1965", :distance=>0, :key_words=>[]},]
108
+
98
109
  ```
99
110
 
100
111
  ## Development
@@ -15,6 +15,7 @@ class DatesFromString
15
15
  @main_arr = []
16
16
  data_arr = string.split(" ")
17
17
  @indexs = []
18
+ @first_index = []
18
19
 
19
20
  data_arr.each_with_index do |data, index|
20
21
  value_year = get_year(data)
@@ -128,6 +129,7 @@ class DatesFromString
128
129
  def add_to_structure (type ,value, index, next_index, data_arr, key_word = nil)
129
130
  set_structura
130
131
  if value
132
+ @first_index << index
131
133
  @structura[:type] = type
132
134
  @structura[:value] = value
133
135
  end
@@ -155,6 +157,8 @@ class DatesFromString
155
157
  @indexs << index
156
158
  if @indexs.count > 1
157
159
  result = (index - @indexs[-2])
160
+ elsif @first_index[0] < index
161
+ result = (index - @first_index[0])
158
162
  else
159
163
  result = index
160
164
  end
@@ -1,3 +1,3 @@
1
1
  class DatesFromString
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dates_from_string
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Chechaev