Class: PairKit::JsonSchema::Dsl::ArrayScaffold
- Defined in:
- lib/pair_kit/json_schema/dsl/scaffolds/array_scaffold.rb
Instance Method Summary collapse
- #+(arr) ⇒ Object
- #<<(item) ⇒ Object
- #first ⇒ Object
-
#initialize(val) ⇒ ArrayScaffold
constructor
A new instance of ArrayScaffold.
- #last ⇒ Object
- #to_schema ⇒ Object
Methods inherited from Scaffold
Constructor Details
#initialize(val) ⇒ ArrayScaffold
Returns a new instance of ArrayScaffold.
5 6 7 |
# File 'lib/pair_kit/json_schema/dsl/scaffolds/array_scaffold.rb', line 5 def initialize(val) @array = val.is_a?(ArrayScaffold) ? val.array : val.map { |x| Scaffold.wrap(x) } end |
Instance Method Details
#+(arr) ⇒ Object
26 27 28 29 30 |
# File 'lib/pair_kit/json_schema/dsl/scaffolds/array_scaffold.rb', line 26 def +(arr) ArrayScaffold.new([]).tap do |scf| scf.array = array + ArrayScaffold.new(arr).array end end |
#<<(item) ⇒ Object
10 11 12 |
# File 'lib/pair_kit/json_schema/dsl/scaffolds/array_scaffold.rb', line 10 def <<(item) @array << Scaffold.wrap(item) end |
#first ⇒ Object
18 19 20 |
# File 'lib/pair_kit/json_schema/dsl/scaffolds/array_scaffold.rb', line 18 def first @array.first end |
#last ⇒ Object
22 23 24 |
# File 'lib/pair_kit/json_schema/dsl/scaffolds/array_scaffold.rb', line 22 def last @array.last end |
#to_schema ⇒ Object
14 15 16 |
# File 'lib/pair_kit/json_schema/dsl/scaffolds/array_scaffold.rb', line 14 def to_schema @array.map(&:to_schema) end |