Skip to content

Commit

Permalink
Align info method names with the C++ API.
Browse files Browse the repository at this point in the history
The pattern is `samples` -> `num_samples`.

Fixes #18.
  • Loading branch information
hainesr committed Apr 7, 2019
1 parent 7e640c5 commit 3e9465d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
12 changes: 6 additions & 6 deletions examples/mod-info
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ end
puts "Tracker....: #{mod.tracker}"
puts "Title......: #{mod.title}"
puts "Duration...: #{duration_mins}:#{duration_secs.round(3)}"
puts "Subsongs...: #{mod.subsongs}"
puts "Channels...: #{mod.channels}"
puts "Orders.....: #{mod.orders}"
puts "Patterns...: #{mod.patterns}"
puts "Instruments: #{mod.instruments}"
puts "Samples....: #{mod.samples}"
puts "Subsongs...: #{mod.num_subsongs}"
puts "Channels...: #{mod.num_channels}"
puts "Orders.....: #{mod.num_orders}"
puts "Patterns...: #{mod.num_patterns}"
puts "Instruments: #{mod.num_instruments}"
puts "Samples....: #{mod.num_samples}"
end
12 changes: 6 additions & 6 deletions lib/ffi/openmpt/module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,32 +45,32 @@ def duration
openmpt_module_get_duration_seconds(@mod)
end

def subsongs
def num_subsongs
return if closed?
openmpt_module_get_num_subsongs(@mod)
end

def channels
def num_channels
return if closed?
openmpt_module_get_num_channels(@mod)
end

def orders
def num_orders
return if closed?
openmpt_module_get_num_orders(@mod)
end

def patterns
def num_patterns
return if closed?
openmpt_module_get_num_patterns(@mod)
end

def instruments
def num_instruments
return if closed?
openmpt_module_get_num_instruments(@mod)
end

def samples
def num_samples
return if closed?
openmpt_module_get_num_samples(@mod)
end
Expand Down
26 changes: 13 additions & 13 deletions test/openmpt_module_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,26 +73,26 @@ def test_open_block_and_change_sample_rate
def test_informational_calls
m = ::FFI::OpenMPT::Module.open(MOD_LAST_SUN) do |mod|
assert_in_epsilon mod.duration, 236.4, 0.001
assert_equal mod.subsongs, 1
assert_equal mod.channels, 4
assert_equal mod.orders, 35
assert_equal mod.patterns, 20
assert_equal mod.instruments, 0
assert_equal mod.samples, 15
assert_equal mod.num_subsongs, 1
assert_equal mod.num_channels, 4
assert_equal mod.num_orders, 35
assert_equal mod.num_patterns, 20
assert_equal mod.num_instruments, 0
assert_equal mod.num_samples, 15
end

assert_nil m.duration
assert_nil m.subsongs
assert_nil m.channels
assert_nil m.orders
assert_nil m.patterns
assert_nil m.instruments
assert_nil m.samples
assert_nil m.num_subsongs
assert_nil m.num_channels
assert_nil m.num_orders
assert_nil m.num_patterns
assert_nil m.num_instruments
assert_nil m.num_samples
end

def test_sample_name
::FFI::OpenMPT::Module.open(MOD_LAST_SUN) do |mod|
mod.samples.times do |i|
mod.num_samples.times do |i|
assert_equal mod.sample_name(i), SAMPLE_NAMES_LAST_SUN[i]
end
end
Expand Down

0 comments on commit 3e9465d

Please sign in to comment.