Class: Envo::PathVal

Inherits:
Object
  • Object
show all
Defined in:
lib/envo/val/path_val.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, str) ⇒ PathVal

Returns a new instance of PathVal.



3
4
5
6
# File 'lib/envo/val/path_val.rb', line 3

def initialize(host, str)
  @host = host
  @path = str
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



7
8
9
# File 'lib/envo/val/path_val.rb', line 7

def host
  @host
end

#pathObject

Returns the value of attribute path.



8
9
10
# File 'lib/envo/val/path_val.rb', line 8

def path
  @path
end

Instance Method Details

#accept_assign?(other) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/envo/val/path_val.rb', line 13

def accept_assign?(other)
  other.type == type
end

#clean!Object



37
38
39
# File 'lib/envo/val/path_val.rb', line 37

def clean!
  @path = nil if @path && !@path.empty? && !@host.path_exists?(@path)
end

#invalid_descriptionObject



16
17
18
# File 'lib/envo/val/path_val.rb', line 16

def invalid_description
  @host.path_exists?(@path) ? nil : 'non-existing path'
end

#list?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/envo/val/path_val.rb', line 19

def list?
  false
end

#pretty_print(ctx) ⇒ Object



28
29
30
31
32
33
# File 'lib/envo/val/path_val.rb', line 28

def pretty_print(ctx)
  ctx.puts @path
  inv = invalid_description
  return if !inv
  ctx.warn "Warning: #{inv}"
end

#to_env_sObject



34
35
36
# File 'lib/envo/val/path_val.rb', line 34

def to_env_s
  @path
end

#to_listObject



22
23
24
# File 'lib/envo/val/path_val.rb', line 22

def to_list
  return PathListVal.new(@host, [@path])
end

#to_sObject



25
26
27
# File 'lib/envo/val/path_val.rb', line 25

def to_s
  @path
end

#typeObject

casts



10
11
12
# File 'lib/envo/val/path_val.rb', line 10

def type
  :path
end