Ruby 如何解析该文件呢?

mobiwolf · April 18, 2012 · Last by mobiwolf replied at April 18, 2012 · 1891 hits
;----------------------
; Xpadder Profile File
;----------------------

Version=5.6

[Profile Settings]

[Set Settings]
Set1DPadMode=FourWay

[Assignments]
Set1Button1Slots=Z
Set1Button2Slots=Enter
Set1Button3Slots=A
Set1Button5Slots=Escape
Set1Button7Slots=Left Shift
Set1Button8Slots=Space
Set1DPadUpSlots=Arrow Up
Set1DPadRightSlots=Arrow Right
Set1DPadDownSlots=Arrow Down
Set1DPadLeftSlots=Arrow Left

如上文件,我想用 ruby 解析此文件。

我需要的流程“ 1,打开此文件 2,读取 [Assignments] 节 3,把 [Assignments] 下面的所有数据都按照 k/v 格式读取出来

如何读取呢?

有 gem: inifile,iniparse,ini ......

@skandhas 貌似 iniparse 1.1.5 是用的比较多的吧?

You need to Sign in before reply, if you don't have an account, please Sign up first.