Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/opswalrus/patches.rb,
lib/opswalrus/patches.rb,
lib/opswalrus/walrus_lang.rb

Direct Known Subclasses

SSHKit::InteractionHandler::Password

Instance Method Summary collapse

Instance Method Details

#boolean!(default: false) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
# File 'lib/opswalrus/patches.rb', line 92

def boolean!(default: false)
  boolean_str = strip.downcase
  case boolean_str
  when "true"
    true
  when "false"
    false
  else
    default
  end
end

#escape_single_quotesObject



72
73
74
# File 'lib/opswalrus/patches.rb', line 72

def escape_single_quotes
  gsub("'"){"\\'"}
end

#integer!(default: 0) ⇒ Object



108
109
110
# File 'lib/opswalrus/patches.rb', line 108

def integer!(default: 0)
  to_i
end

#mustache(bindings_from_stack_frame_offset = 0) ⇒ Object

bindings_from_stack_frame_offset is a count relative to the stack from from which #mustache is called



78
79
80
81
# File 'lib/opswalrus/walrus_lang.rb', line 78

def mustache(bindings_from_stack_frame_offset = 0)
  base_offset = 2
  WalrusLang.eval(self, base_offset + bindings_from_stack_frame_offset)
end

#parse_jsonObject



80
81
82
# File 'lib/opswalrus/patches.rb', line 80

def parse_json
  JSON.parse(self)
end

#render_template(hash) ⇒ Object



73
74
75
# File 'lib/opswalrus/walrus_lang.rb', line 73

def render_template(hash)
  WalrusLang.render(self, hash)
end

#string!(default: "") ⇒ Object



104
105
106
# File 'lib/opswalrus/patches.rb', line 104

def string!(default: "")
  self
end

#to_pathnameObject



76
77
78
# File 'lib/opswalrus/patches.rb', line 76

def to_pathname
  Pathname.new(self)
end