ruby language syntax(how platform_info variable is used
class EncodeDemoTest < Test #inheritance in ruby
def setup(platform_info, logdir)
@telnet_ip = platform_info["telnet_ip"]
@telnet_login = platform_info["telnet_login"]
@telnet_password = nil
@filesys_path = platform_info["filesys_path"]
@host_files_path = platform_info["host_files_path"]
@host_machine_ip = platform_info["host_machine_ip"]
@linuxserver_ip = platform_info["linuxserver_ip"]
@target_prompt = platform_info["target_prompt"]
@demo_execuable_path = platform_info["demo_execuable_path"]
@mts4ea_machine_ip = platform_info["mts4ea_machine_ip"]
@mts4ea_files_path = platform_info["mts4ea_files_path"]
@ffmpeg_machine_ip = platform_info["ffmpeg_machine_ip"]
@ffmpeg_service_machine_ip = platf开发者_JS百科orm_info["ffmpeg_service_machine_ip"]
@ffmpeg_files_path = platform_info["ffmpeg_files_path"]
@ffmpeg_login = platform_info["ffmpeg_login"]
@ffmpeg_password = platform_info["ffmpeg_password"]
@ffmpeg_prompt = platform_info["ffmpeg_prompt"]
@platform_info = platform_info
could anyone tell me how argument passed in setup method .means what does that syntax means platform_info["telnet_ip"]
It looks like platform_info
is intended to be a Hash.
setup
would be called with something like setup({'telnet_ip' => 'value'}, 'logdir_value')
and platform_info["telnet_ip"]
would then return the value from platform_info
for the key "telnet_ip"
.
Update
Given the code:
@board = Target::TelnetClient.new "192.168.247.68", "root",
@telnet_password, logdir + "/log.txt"
app = Target::EncodeDemoApp.new() app.setup(@board, @demo_execuable_path)
it looks like @board
is not a Hash
but is a Target::TelnetClient
which must have a []
method that makes it behave like a Hash
.
If you want to find out what class something is you can use the class
method e.g. you can put in your program:
puts "@board is a #{@board.class}"
puts "@demo_executable_path is a #{@demo_executable_path.class}"
For @board
, to see what values it contains (telnet_ip, telnet_login etc) you could try:
puts @board.keys.inspect
Finally, to see the methods that an object provides you can use public_methods
e.g.
puts @board.public_methods.inspect
精彩评论