udat 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/udat.rb +17 -9
- metadata +2 -2
data/lib/udat.rb
CHANGED
@@ -545,9 +545,17 @@ class UdatCollection < Udat
|
|
545
545
|
synchronize do
|
546
546
|
key_value_pair = @entries.delete_at(index)
|
547
547
|
rehash
|
548
|
-
return key_value_pair ? key_value_pair[
|
548
|
+
return key_value_pair ? key_value_pair[1] : nil
|
549
549
|
end
|
550
550
|
end
|
551
|
+
# Deletes the first entry and returns its value.
|
552
|
+
def shift
|
553
|
+
delete_at(0)
|
554
|
+
end
|
555
|
+
# Deletes the last entry and returns its value.
|
556
|
+
def pop
|
557
|
+
delete_at(-1)
|
558
|
+
end
|
551
559
|
# Deletes all entries with a given key.
|
552
560
|
def delete_key(key)
|
553
561
|
key = key.to_udat
|
@@ -623,22 +631,22 @@ class UdatCollection < Udat
|
|
623
631
|
set_value_for_key(key, value)
|
624
632
|
end
|
625
633
|
|
626
|
-
# Returns the
|
627
|
-
# bounds
|
628
|
-
def
|
634
|
+
# Returns the value at a numeric index, or nil, if the index is out of
|
635
|
+
# bounds.
|
636
|
+
def value_by_index(index)
|
629
637
|
index = index.to_int
|
630
638
|
synchronize do
|
631
639
|
entry = @entries[index]
|
632
|
-
return entry ? entry[
|
640
|
+
return entry ? entry[1] : nil
|
633
641
|
end
|
634
642
|
end
|
635
|
-
# Returns the
|
636
|
-
# bounds.
|
637
|
-
def
|
643
|
+
# Returns the key at a numeric index, or nil, if the index is out of
|
644
|
+
# bounds or at the given index there is only a value without key.
|
645
|
+
def key_by_index(index)
|
638
646
|
index = index.to_int
|
639
647
|
synchronize do
|
640
648
|
entry = @entries[index]
|
641
|
-
return entry ? entry[
|
649
|
+
return entry ? entry[0] : nil
|
642
650
|
end
|
643
651
|
end
|
644
652
|
# Returns an Array of values having a given key.
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: udat
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.2.
|
7
|
-
date: 2007-05-
|
6
|
+
version: 1.2.1
|
7
|
+
date: 2007-05-26 00:00:00 +00:00
|
8
8
|
summary: Parser and generator for UDAT documents, a generic data format similar to XML or YAML.
|
9
9
|
require_paths:
|
10
10
|
- lib/
|