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.



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

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

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



64
65
66
# File 'lib/ruby-wpdb/config.rb', line 64

def filename
  @filename
end

Instance Method Details

#configObject



81
82
83
# File 'lib/ruby-wpdb/config.rb', line 81

def config
  format.new(filename).config
end

#formatObject



70
71
72
73
74
75
76
77
78
79
# File 'lib/ruby-wpdb/config.rb', line 70

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