Class: Fig::Deparser::V0

Inherits:
Object
  • Object
show all
Includes:
Fig::Deparser
Defined in:
lib/fig/deparser/v0.rb

Overview

Handles serializing of statements in the v0 grammar.

Instance Method Summary collapse

Methods included from Fig::Deparser

#archive, class_for_statements, #configuration, #deparse, determine_version_and_deparse, #include, #include_file, #override, #path, #resource, #set, #synthetic_raw_text

Constructor Details

#initialize(emit_as_input_or_to_be_published_values, indent_string = ' ' * 2, initial_indent_level = 0) ⇒ V0

Returns a new instance of V0.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fig/deparser/v0.rb', line 10

def initialize(
  emit_as_input_or_to_be_published_values,
  indent_string = ' ' * 2,
  initial_indent_level = 0
)
  @emit_as_input_or_to_be_published_values =
    emit_as_input_or_to_be_published_values
  @indent_string        = indent_string
  @initial_indent_level = initial_indent_level

  return
end

Instance Method Details

#command(statement) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/fig/deparser/v0.rb', line 23

def command(statement)
  add_indent

  @text << %q<command ">
  @text << statement.command.first.to_double_quotable_string
  @text << %Q<"\n>

  return
end

#grammar_descriptionObject



54
55
56
# File 'lib/fig/deparser/v0.rb', line 54

def grammar_description()
  return 'v0'
end

#grammar_version(statement) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/fig/deparser/v0.rb', line 33

def grammar_version(statement)
  add_indent

  # Comment out so that older clients don't have issues.
  @text << "# grammar v0\n"

  return
end

#retrieve(statement) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fig/deparser/v0.rb', line 42

def retrieve(statement)
  add_indent

  @text << 'retrieve '
  @text << statement.variable
  @text << '->'
  @text << statement.tokenized_path.to_double_quotable_string
  @text << "\n"

  return
end