Class: WPDB::Config::AutoFormat

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-wpdb/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ AutoFormat

Returns a new instance of AutoFormat.



69
70
71
# File 'lib/ruby-wpdb/config.rb', line 69

def initialize(filename)
  @filename = Pathname(filename)
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



67
68
69
# File 'lib/ruby-wpdb/config.rb', line 67

def filename
  @filename
end

Instance Method Details

#configObject



84
85
86
# File 'lib/ruby-wpdb/config.rb', line 84

def config
  format.new(filename).config
end

#formatObject



73
74
75
76
77
78
79
80
81
82
# File 'lib/ruby-wpdb/config.rb', line 73

def format
  case filename.extname
  when ".yml", ".yaml"
    Config::YAML
  when ".php"
    Config::WPConfig
  else
    nil
  end
end