Module: INIH
- Defined in:
- lib/inih.rb,
lib/inih/version.rb,
lib/inih/exceptions.rb,
ext/inih/inih.c
Overview
The primary namespace for INIH.
Defined Under Namespace
Classes: INIHError, ParseError
Constant Summary collapse
- VERSION =
The current version of ruby-inih.
"2.0.1"
Class Method Summary collapse
-
.load(filename, normalize: true) ⇒ Hash
Parse an INI-formatted file into a Hash.
- .load_intern(filename, normalize) ⇒ Object private
-
.normalize_hash(hsh) ⇒ Object
private
Normalize a parsed INI file's values.
-
.normalize_sect(sect) ⇒ Object
private
Normalize the values in a section of a parsed INI file.
-
.parse(string, normalize: true) ⇒ Hash
Parse an INI-formatted string into a Hash.
- .parse_intern(string, normalize) ⇒ Object private
Class Method Details
.load(filename, normalize: true) ⇒ Hash
Parse an INI-formatted file into a Hash.
25 26 27 |
# File 'lib/inih.rb', line 25 def load(filename, normalize: true) load_intern filename, normalize end |
.load_intern(filename, normalize) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 |
# File 'ext/inih/inih.c', line 18
static VALUE mINIH_load_intern(VALUE self, VALUE filename, VALUE normalize);
|
.normalize_hash(hsh) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Normalize a parsed INI file's values.
31 32 33 34 35 |
# File 'lib/inih.rb', line 31 def normalize_hash(hsh) hsh.map do |k, sect| [k, normalize_sect(sect)] end.to_h end |
.normalize_sect(sect) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Normalize the values in a section of a parsed INI file.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/inih.rb', line 39 def normalize_sect(sect) sect.map do |k, v| nv = case v when "" then nil when "true" then true when "false" then false when /\A-?\d+\Z/ then Integer v when /\A-?\d+\.\d+\Z/ then Float v else v end [k, nv] end.to_h end |
.parse(string, normalize: true) ⇒ Hash
Parse an INI-formatted string into a Hash.
15 16 17 |
# File 'lib/inih.rb', line 15 def parse(string, normalize: true) parse_intern string, normalize end |
.parse_intern(string, normalize) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 |
# File 'ext/inih/inih.c', line 12
static VALUE mINIH_parse_intern(VALUE self, VALUE string, VALUE normalize);
|