Flex Message Meta
Flex Message Meta是每一個Flex Message一定會包含的部分,其Json為
{
  "type": "flex",
  "altText": "this is a flex message",
  "contents": {...}
}
對應的Kamiflex程式碼為
json = Kamiflex.json(self) do
  ...
end
puts json
Kamiflex 會將該程式碼轉換為JSON,do...end為block,可以在其中放入 核心元件。
Class Method
下列為 Kamiflex 可以使用的 Class Method:
- .hash - 使用 - Kamiflex.hash會傳回 Hash。
- .json - 使用 - Kamiflex.json會傳回 JSON。
可用的引數
- parent (必填) 此引數用於指定執行 Kamiflex 區塊的物件,其目的是為了在 Kamiflex 區塊中可以獲得變數的值以及呼叫方法,通常會傳入 self。
區塊中的方法
- alt_text
使用範例
Ruby 寫法:
json = Kamiflex.json(self) do
  alt_text "test alt text"
  bubble do
    body do
      text "Hello, World!"
    end
  end
end
puts json
對應的 JSON:
{
  "type": "flex",
  "altText": "test alt text",
  "contents": {
    "type": "bubble",
    "body": {
      "type": "box",
      "layout": "vertical",
      "contents": [
        {
          "type": "text",
          "text": "Hello, World!"
        }
      ]
    }
  }
}
運行結果
