Skip to content

Commit

Permalink
Method aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
dag committed May 1, 2008
1 parent b19f2cf commit 7819d94
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
22 changes: 11 additions & 11 deletions README.mkdn
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,24 @@ Here is a list of all exceptions in the `Statgrab` namespace:

### Instance methods

- `cpu_stats`
- `cpu_stats_diff`
Methods are named as in libstatgrab but without the `sg_get_`
prefix, and some also have aliases, usually either shorter
or more rubyistic.

- `cpu_stats`, `cpu`
- `cpu_stats_diff`, `cpu_difference`
- `cpu_percents`
- `disk_io_stats`
- `disk_io_stats_diff`
- `fs_stats`
- `disk_io_stats`, `disk_io`
- `disk_io_stats_diff`, `disk_io_difference`
- `fs_stats`, `fs`, `file_system`

Somewhat relevant information is available for every method
supplied with libstatgrab as manual pages:

man sg_get_<method>

Just remember all structs are represented as symbol hashes.
If you prefer a more struct-like behavior, use `ostruct`:

require 'ostruct'
percents = OpenStruct.new(sg.cpu_percents)
puts percents.user
Where `<method>` is not an alias. Also remember all
structs are represented as symbol hashes.

Sample program
--------------
Expand Down
6 changes: 6 additions & 0 deletions statgrab.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,15 @@ void Init_statgrab() {
eStatgrabXswVerMismatchError = rb_define_class_under(cStatgrab, "XswVerMismatchError", eStatgrabException);
rb_define_method(cStatgrab, "initialize", statgrab_initialize, -2);
rb_define_method(cStatgrab, "cpu_stats", statgrab_cpu_stats, 0);
rb_define_method(cStatgrab, "cpu", statgrab_cpu_stats, 0);
rb_define_method(cStatgrab, "cpu_stats_diff", statgrab_cpu_stats_diff, 0);
rb_define_method(cStatgrab, "cpu_difference", statgrab_cpu_stats_diff, 0);
rb_define_method(cStatgrab, "cpu_percents", statgrab_cpu_percents, 0);
rb_define_method(cStatgrab, "disk_io_stats", statgrab_disk_io_stats, 0);
rb_define_method(cStatgrab, "disk_io", statgrab_disk_io_stats, 0);
rb_define_method(cStatgrab, "disk_io_stats_diff", statgrab_disk_io_stats_diff, 0);
rb_define_method(cStatgrab, "disk_io_difference", statgrab_disk_io_stats_diff, 0);
rb_define_method(cStatgrab, "fs_stats", statgrab_fs_stats, 0);
rb_define_method(cStatgrab, "fs", statgrab_fs_stats, 0);
rb_define_method(cStatgrab, "file_system", statgrab_fs_stats, 0);
}

0 comments on commit 7819d94

Please sign in to comment.