forked from aws/aws-sdk-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathempty_structure.rb
84 lines (66 loc) · 1.14 KB
/
empty_structure.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
module Aws
class EmptyStructure < Structure
def self.new
super([])
end
def ==(other)
other.is_a?(EmptyStructure)
end
def [](member_name)
raise NameError, "no member '#{member_name}' in struct"
end
def []=(member_name, value)
raise NameError, "no member '#{member_name}' in struct"
end
def each(&block)
unless block_given?
[].to_enum
end
end
def each_pair(&block)
unless block_given?
{}.to_enum
end
end
def eql?(other)
other.is_a?(EmptyStructure)
end
# @api private
def inspect
'#<struct>'
end
# @api private
def pretty_print(q)
q.text(inspect)
end
def length
0
end
def members
[]
end
def select(&block)
[]
end
def size
0
end
def to_a
[]
end
def to_h
{}
end
def values
[]
end
def values_at(*selector)
if selector.empty?
[]
else
offset = selector.first
raise IndexError, "offset #{offset} too large for struct(size:0)"
end
end
end
end