A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.aws.amazon.com/sdkforruby/api/Aws/Resources/Source.html below:

Source — AWS SDK for Ruby V2

You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Aws::Resources::Source
Inherits:
Object show all
Defined in:
aws-sdk-resources/lib/aws-sdk-resources/source.rb
Instance Attribute Summary collapse Instance Method Summary collapse Constructor Details #initialize(definition, file = nil) ⇒ Source

Returns a new instance of Source.

7
8
9
10
# File 'aws-sdk-resources/lib/aws-sdk-resources/source.rb', line 7

def initialize(definition, file = nil)
  @definition = definition
  @file = file
end
Instance Attribute Details #definition ⇒ Hash
13
14
15
# File 'aws-sdk-resources/lib/aws-sdk-resources/source.rb', line 13

def definition
  @definition
end
#file ⇒ String?
16
17
18
# File 'aws-sdk-resources/lib/aws-sdk-resources/source.rb', line 16

def file
  @file
end
Instance Method Details #format ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'aws-sdk-resources/lib/aws-sdk-resources/source.rb', line 18

def format
  json = JSON.pretty_generate(definition, indent: '  ', space: '')
  stack = [[]]
  json.lines.each do |line|
    if line.match(/({|\[)$/)
      stack.push([])
    end
    stack.last.push(line)
    if line.match(/(}|\]),?$/)
      frame = stack.pop
      if frame.size == 3 && !frame[1].match(/[{}]/)
        frame = [frame[0].rstrip, '', frame[1].strip, '', frame[2].lstrip]
      end
      stack.last.push(frame.join)
    end
  end
  stack.last.join
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4