udat 1.2.0 → 1.2.1

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.
Files changed (2) hide show
  1. data/lib/udat.rb +17 -9
  2. metadata +2 -2
@@ -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[0] : nil
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 key at a numeric index, or nil, if the index is out of
627
- # bounds or at the given index there is only a value without key.
628
- def key_by_index(index)
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[0] : nil
640
+ return entry ? entry[1] : nil
633
641
  end
634
642
  end
635
- # Returns the value at a numeric index, or nil, if the index is out of
636
- # bounds.
637
- def value_by_index(index)
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[1] : nil
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.0
7
- date: 2007-05-25 00:00:00 +00:00
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/